Merge branch 'testing_branch' of https://gitlab.com/Crondung/hsma_cpd into testing_branch
commit
7b4d7abe4e
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue