-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #352 from CollActionteam/tests/fix-and-add-tests
tests: add and fix tests
- Loading branch information
Showing
20 changed files
with
1,022 additions
and
195 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
41 changes: 41 additions & 0 deletions
41
test/application/build_information/build_information_bloc_test.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,41 @@ | ||
import 'package:bloc_test/bloc_test.dart'; | ||
import 'package:collaction_app/application/settings/build_information/build_information_bloc.dart'; | ||
|
||
import 'package:collaction_app/domain/settings/build_information.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
|
||
import '../../domain/core/i_settings_repository.mocks.dart'; | ||
|
||
void main() { | ||
group('Testing Build Information BLoC', () { | ||
late final SettingsRepositoryMock settingsRepository; | ||
late final BuildInformationBloc bloc; | ||
|
||
setUpAll(() { | ||
settingsRepository = SettingsRepositoryMock(); | ||
bloc = BuildInformationBloc(settingsRepository); | ||
}); | ||
|
||
test('Initial state', () { | ||
expect(bloc.state, const BuildInformationState.loading()); | ||
}); | ||
|
||
blocTest( | ||
'Fetch', | ||
build: () => bloc, | ||
act: (bloc) { | ||
when(() => settingsRepository.getBuildInformation()) | ||
.thenAnswer((_) => Future.value(tBuildInformation)); | ||
|
||
bloc.add(BuildInformationEvent.fetch()); | ||
}, | ||
expect: () => [ | ||
const BuildInformationState.loading(), | ||
BuildInformationState.fetched(tBuildInformation), | ||
], | ||
); | ||
}); | ||
} | ||
|
||
final tBuildInformation = BuildInformation(version: '1.0.0', buildNumber: '1'); |
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
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,69 @@ | ||
import 'package:bloc_test/bloc_test.dart'; | ||
import 'package:collaction_app/application/username/username_bloc.dart'; | ||
import 'package:collaction_app/domain/user/profile_failure.dart'; | ||
|
||
import 'package:dartz/dartz.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mocktail/mocktail.dart'; | ||
|
||
import '../../test_utilities.dart'; | ||
|
||
void main() { | ||
group('Testing Username BLoC', () { | ||
late final MockProfileRepository profileRepository; | ||
late UsernameBloc bloc; | ||
|
||
setUpAll(() { | ||
profileRepository = MockProfileRepository(); | ||
bloc = UsernameBloc(profileRepository); | ||
}); | ||
|
||
setUp(() { | ||
// Reset BLOC | ||
bloc = UsernameBloc(profileRepository); | ||
}); | ||
|
||
test('Initial state', () { | ||
expect(bloc.state, const UsernameState.initial()); | ||
}); | ||
|
||
blocTest( | ||
'Update username success', | ||
build: () => bloc, | ||
act: (bloc) { | ||
when(() => profileRepository.updateUsername( | ||
firstName: tFirstName, lastName: tLastName)).thenAnswer( | ||
(_) => Future.value(right(unit)), | ||
); | ||
|
||
bloc.add(UsernameEvent.updateUsername( | ||
firstName: tFirstName, lastName: tLastName)); | ||
}, | ||
expect: () => [ | ||
const UsernameState.updateInProgress(), | ||
UsernameState.updateSuccess('$tFirstName $tLastName'), | ||
], | ||
); | ||
|
||
blocTest( | ||
'Update username failure', | ||
build: () => bloc, | ||
act: (bloc) { | ||
when(() => profileRepository.updateUsername( | ||
firstName: tFirstName, lastName: tLastName)).thenAnswer( | ||
(_) => Future.value(left(ProfileFailure.unexpected())), | ||
); | ||
|
||
bloc.add(UsernameEvent.updateUsername( | ||
firstName: tFirstName, lastName: tLastName)); | ||
}, | ||
expect: () => [ | ||
const UsernameState.updateInProgress(), | ||
const UsernameState.updateFailure(), | ||
], | ||
); | ||
}); | ||
} | ||
|
||
final tFirstName = "Mathias"; | ||
final tLastName = "M"; |
Oops, something went wrong.