Merge branch 'testing_branch' of https://gitlab.com/Crondung/hsma_cpd into testing_branch

main
Kai Mannweiler 2023-03-06 22:16:56 +01:00
commit 7b4d7abe4e
1 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,41 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import 'package:provider/provider.dart';
import 'package:smoke_cess_app/providers/settings_provider.dart';
import 'package:smoke_cess_app/widgets/buttons/text_icon_button.dart';
import 'package:smoke_cess_app/widgets/scanner.dart';
import '../mock/settings_mock.dart';
void main() {
mockSharedPreferences();
group('MyScanner', () {
testWidgets('Scanner should start after Button is pressed',
(widgetTester) async {
SettingsProvider settingsProvider = SettingsProvider();
expect(settingsProvider.scanning, false);
await widgetTester.pumpWidget(MaterialApp(
home: Column(
children: [
ChangeNotifierProvider(
create: (context) => settingsProvider, child: const MyScanner())
],
),
));
final startScannerButton = find.byType(TextIconButton);
final scanner = find.byType(MobileScanner);
expect(startScannerButton, findsOneWidget);
expect(scanner, findsNothing);
await widgetTester.tap(startScannerButton);
await widgetTester.pump();
expect(startScannerButton, findsNothing);
expect(scanner, findsOneWidget);
expect(settingsProvider.scanning, true);
});
});
}