mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 16:30:40 +00:00
fixed tests
This commit is contained in:
parent
efd3dc2586
commit
4e6f9dff17
3 changed files with 49 additions and 2 deletions
|
@ -153,8 +153,6 @@ void testE2E(String description) {
|
||||||
/// Delete profile
|
/// Delete profile
|
||||||
await tester.openSettings();
|
await tester.openSettings();
|
||||||
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
await tester.tapDescendantTextOf<SettingsScreen>(S.current.equipmentProfiles);
|
||||||
await tester.tap(find.text(mockEquipmentProfiles[0].name).first);
|
|
||||||
await tester.pumpAndSettle();
|
|
||||||
await tester.tap(find.byIcon(Icons.edit).first);
|
await tester.tap(find.byIcon(Icons.edit).first);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
await tester.deleteEdits();
|
await tester.deleteEdits();
|
||||||
|
|
|
@ -22,6 +22,7 @@ void main() {
|
||||||
() => storageService.updateProfile(
|
() => storageService.updateProfile(
|
||||||
id: any<String>(named: 'id'),
|
id: any<String>(named: 'id'),
|
||||||
name: any<String>(named: 'name'),
|
name: any<String>(named: 'name'),
|
||||||
|
isUsed: any<bool>(named: 'isUsed'),
|
||||||
),
|
),
|
||||||
).thenAnswer((_) async {});
|
).thenAnswer((_) async {});
|
||||||
when(() => storageService.deleteProfile(any<String>())).thenAnswer((_) async {});
|
when(() => storageService.deleteProfile(any<String>())).thenAnswer((_) async {});
|
||||||
|
@ -55,6 +56,10 @@ void main() {
|
||||||
expect(find.text(_EquipmentProfilesCount.text(count)), findsOneWidget);
|
expect(find.text(_EquipmentProfilesCount.text(count)), findsOneWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void expectEquipmentProfilesInUseCount(int count) {
|
||||||
|
expect(find.text(_EquipmentProfilesInUseCount.text(count)), findsOneWidget);
|
||||||
|
}
|
||||||
|
|
||||||
void expectSelectedEquipmentProfileName(String name) {
|
void expectSelectedEquipmentProfileName(String name) {
|
||||||
expect(find.text(_SelectedEquipmentProfile.text(name)), findsOneWidget);
|
expect(find.text(_SelectedEquipmentProfile.text(name)), findsOneWidget);
|
||||||
}
|
}
|
||||||
|
@ -96,6 +101,26 @@ void main() {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'toggleProfile',
|
||||||
|
(tester) async {
|
||||||
|
when(() => storageService.selectedEquipmentProfileId).thenReturn(_customProfiles.first.id);
|
||||||
|
await pumpTestWidget(tester, IAPProductStatus.purchased);
|
||||||
|
expectEquipmentProfilesCount(_customProfiles.length + 1);
|
||||||
|
expectEquipmentProfilesInUseCount(_customProfiles.length + 1);
|
||||||
|
expectSelectedEquipmentProfileName(_customProfiles.first.name);
|
||||||
|
|
||||||
|
await tester.equipmentProfilesProvider.toggleProfile(_customProfiles.first, false);
|
||||||
|
await tester.pump();
|
||||||
|
expectEquipmentProfilesCount(_customProfiles.length + 1);
|
||||||
|
expectEquipmentProfilesInUseCount(_customProfiles.length + 1 - 1);
|
||||||
|
expectSelectedEquipmentProfileName('');
|
||||||
|
|
||||||
|
verify(() => storageService.updateProfile(id: _customProfiles.first.id, isUsed: false)).called(1);
|
||||||
|
verify(() => storageService.selectedEquipmentProfileId = '').called(1);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
testWidgets(
|
testWidgets(
|
||||||
'EquipmentProfilesProvider CRUD',
|
'EquipmentProfilesProvider CRUD',
|
||||||
(tester) async {
|
(tester) async {
|
||||||
|
@ -167,6 +192,7 @@ class _Application extends StatelessWidget {
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
_EquipmentProfilesCount(),
|
_EquipmentProfilesCount(),
|
||||||
|
_EquipmentProfilesInUseCount(),
|
||||||
_SelectedEquipmentProfile(),
|
_SelectedEquipmentProfile(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -187,6 +213,17 @@ class _EquipmentProfilesCount extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _EquipmentProfilesInUseCount extends StatelessWidget {
|
||||||
|
static String text(int count) => "Profiles in use count: $count";
|
||||||
|
|
||||||
|
const _EquipmentProfilesInUseCount();
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Text(text(EquipmentProfiles.inUseOf(context).length));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class _SelectedEquipmentProfile extends StatelessWidget {
|
class _SelectedEquipmentProfile extends StatelessWidget {
|
||||||
static String text(String name) => "Selected profile: $name}";
|
static String text(String name) => "Selected profile: $name}";
|
||||||
|
|
||||||
|
|
|
@ -79,6 +79,18 @@ void main() {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
testWidgets(
|
||||||
|
'Equipment profile picker shows only profiles in use',
|
||||||
|
(tester) async {
|
||||||
|
when(() => storageService.getProfiles())
|
||||||
|
.thenAnswer((_) async => _mockEquipmentProfiles.skip(1).toList().toSelectableMap());
|
||||||
|
await pumpApplication(tester);
|
||||||
|
await tester.openAnimatedPicker<EquipmentProfilePicker>();
|
||||||
|
expectRadioListTile<EquipmentProfile>(S.current.none, isSelected: true);
|
||||||
|
expectRadioListTile<EquipmentProfile>(_mockEquipmentProfiles[1].name);
|
||||||
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final _mockEquipmentProfiles = [
|
final _mockEquipmentProfiles = [
|
||||||
|
|
Loading…
Reference in a new issue