This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:io'; | |
import 'package:flutter/material.dart'; | |
import 'package:learn_fazz/app_config.dart'; | |
import 'package:learn_fazz/models/login_result.dart'; | |
import 'package:learn_fazz/pages/dashboard_page.dart'; | |
import 'package:learn_fazz/repositories/auth_repository.dart'; | |
import 'package:learn_fazz/widgets/image_picker_bottom_sheet.dart'; | |
import '../assets/learn_fazz_icons.dart'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when(mockObject.nameOfFunctionToTest()).thenReturn(objectToBeReturned); | |
when(mockObject.nameOfFunctionToTest()).thenThrows(errorToBeReturned); | |
when(mockObject.nameOfFunctionToTest()).thenAnswer(functionToBeExecutedAndReturnsSomeValueWithTheSameTypeWhenMethodIsCalled); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can use plain arguments themselves: | |
when(cat.eatFood("fish")).thenReturn(true); | |
// ... including collections: | |
when(cat.walk(["roof","tree"])).thenReturn(2); | |
// ... or matchers: | |
when(cat.eatFood(argThat(startsWith("dry"))).thenReturn(false); | |
// ... or mix aguments with matchers: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
when(cat.eatFood(any, hungry: anyNamed('hungry'))).thenReturn(0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.something.TargetClass; | |
import static org.mockito.Mockito.*; | |
class TestTargetClass { | |
// first options: use Annotations | |
@Mock | |
TargetClass mockTargetClass; | |
// second options: initialize using mock() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_test/flutter_test.dart'; | |
import 'package:mockito/mockito.dart'; | |
import 'package:something/org/target_class.dart' | |
class MockClass extends Mock implements TargetClass {} | |
TargetClass mockTargetClass = MockClass(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:learn_fazz/models/course_detail_result.dart'; | |
const String courseName = 'Intro to English Grammar'; | |
const String lecturerName = 'Jackson K.'; | |
class CourseListCard extends StatelessWidget { | |
final CourseDetailResult course; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'dart:io'; | |
import 'package:dio/dio.dart'; | |
import 'package:learn_fazz/models/login_spec.dart'; | |
import 'package:learn_fazz/models/login_result.dart'; | |
import 'package:learn_fazz/models/register_spec.dart'; | |
import 'package:learn_fazz/providers/login_provider.dart'; | |
import 'package:learn_fazz/providers/register_provider.dart'; | |
import 'package:meta/meta.dart'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppConfig extends InheritedWidget { | |
AppConfig({@required this.httpClient, Widget child}) | |
: authRepository = AuthRepository(httpClient: httpClient), | |
courseRepository = CourseRepository(httpClient: httpClient), | |
super(child: child); | |
AppConfig.defaultConstructor({String apiBaseUrl}) | |
: this( | |
httpClient: Dio(BaseOptions( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CoursePage extends StatefulWidget { | |
@override | |
_CoursePageState createState() => _CoursePageState(); | |
} | |
class _CoursePageState extends State<CoursePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Container(color: const Color(0xFFFFE306)); | |
} |