42 lines
1.3 KiB
Dart
42 lines
1.3 KiB
Dart
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);
|
|
});
|
|
});
|
|
}
|