-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add forgotten mocks from pincode feature
- Loading branch information
1 parent
4468642
commit e5ed207
Showing
4 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...tes/bricks/lib_pin_code/__brick__/test/lib_pin_code/views/mocks/create_pin_bloc_mock.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import 'package:mockito/annotations.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:rxdart/rxdart.dart'; | ||
import 'package:testapp/lib_pin_code/bloc/create_pin_bloc.dart'; | ||
|
||
import 'create_pin_bloc_mock.mocks.dart'; | ||
|
||
@GenerateMocks([CreatePinBlocType, CreatePinBlocEvents, CreatePinBlocStates]) | ||
CreatePinBlocType createPinMockFactory({ | ||
bool? isPinCreated, | ||
bool? deleteStoredPinData, | ||
}) { | ||
final blocMock = MockCreatePinBlocType(); | ||
final eventsMock = MockCreatePinBlocEvents(); | ||
final statesMock = MockCreatePinBlocStates(); | ||
|
||
when(blocMock.events).thenReturn(eventsMock); | ||
when(blocMock.states).thenReturn(statesMock); | ||
|
||
final isPinCreatedState = (isPinCreated != null | ||
? Stream.value(isPinCreated) | ||
: const Stream<bool>.empty()) | ||
.publishReplay(maxSize: 1) | ||
..connect(); | ||
|
||
final deleteStoredPinDataState = (deleteStoredPinData != null | ||
? Stream.value(deleteStoredPinData) | ||
: const Stream<bool>.empty()) | ||
.publishReplay(maxSize: 1) | ||
..connect(); | ||
|
||
when(statesMock.deleteStoredPinData).thenAnswer( | ||
(_) => deleteStoredPinDataState, | ||
); | ||
|
||
when(statesMock.isPinCreated).thenAnswer((_) => isPinCreatedState); | ||
|
||
return blocMock; | ||
} |
12 changes: 12 additions & 0 deletions
12
.../bricks/lib_pin_code/__brick__/test/lib_pin_code/views/mocks/create_pin_service_mock.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import 'package:mockito/annotations.dart'; | ||
import 'package:testapp/lib_pin_code/repository/pin_code_repository.dart'; | ||
import 'package:testapp/lib_pin_code/services/create_pin_code_service.dart'; | ||
|
||
import 'create_pin_service_mock.mocks.dart'; | ||
|
||
@GenerateMocks([PinCodeRepository]) | ||
CreatePinCodeService createPinServiceMockFactory() { | ||
final repositoryMock = MockPinCodeRepository(); | ||
|
||
return CreatePinCodeService(repositoryMock); | ||
} |
8 changes: 8 additions & 0 deletions
8
...in_code/__brick__/test/lib_pin_code/views/mocks/pin_biometrics_local_datasource_mock.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
import 'package:mockito/annotations.dart'; | ||
import 'package:testapp/lib_pin_code/data_source/pin_biometrics_local_data_source.dart'; | ||
|
||
import 'pin_biometrics_local_datasource_mock.mocks.dart'; | ||
|
||
@GenerateMocks([PinBiometricsLocalDataSource]) | ||
PinBiometricsLocalDataSource pinBiometricsLocalDataSourceMockFactory() => MockPinBiometricsLocalDataSource(); |
33 changes: 33 additions & 0 deletions
33
...lib_pin_code/__brick__/test/lib_pin_code/views/mocks/update_and_verify_pin_bloc_mock.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import 'package:local_session_timeout/local_session_timeout.dart'; | ||
import 'package:mockito/annotations.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:rxdart/rxdart.dart'; | ||
import 'package:testapp/lib_pin_code/bloc/update_and_verify_pin_bloc.dart'; | ||
|
||
import 'update_and_verify_pin_bloc_mock.mocks.dart'; | ||
|
||
@GenerateMocks([ | ||
UpdateAndVerifyPinBlocType, | ||
UpdateAndVerifyPinBlocEvents, | ||
UpdateAndVerifyPinBlocStates | ||
]) | ||
UpdateAndVerifyPinBlocType updateAndVerifyPinMockFactory() { | ||
final blocMock = MockUpdateAndVerifyPinBlocType(); | ||
final eventsMock = MockUpdateAndVerifyPinBlocEvents(); | ||
final statesMock = MockUpdateAndVerifyPinBlocStates(); | ||
|
||
when(blocMock.events).thenReturn(eventsMock); | ||
when(blocMock.states).thenReturn(statesMock); | ||
|
||
final emptyState = Stream.value(null).publishReplay(maxSize: 1) | ||
..connect(); | ||
|
||
when(statesMock.deleteStoredPinData).thenAnswer((_) => emptyState); | ||
when(statesMock.deletedData).thenAnswer((_) => emptyState); | ||
when(statesMock.deleteStoredPinData).thenAnswer((_) => emptyState); | ||
when(statesMock.isPinUpdated).thenAnswer((_) => emptyState); | ||
when(statesMock.sessionValue).thenAnswer((_) => Stream.value(SessionState.stopListening).publishReplay(maxSize: 1) | ||
..connect()); | ||
|
||
return blocMock; | ||
} |