-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
font_picker_test.dart
53 lines (45 loc) · 1.47 KB
/
font_picker_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import 'package:appainter/font/font.dart';
import 'package:appainter/text_theme/text_theme.dart';
import 'package:bloc_test/bloc_test.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:mocktail/mocktail.dart';
import '../mocks.dart';
void main() {
late TextThemeCubit cubit;
setUp(() {
cubit = MockTextThemeCubit();
});
testWidgets('font picker should update font family', (tester) async {
const fontFamily = 'ABeeZee';
final style = GoogleFonts.aBeeZee();
whenListen(
cubit,
Stream.fromIterable([const TextThemeState(fontFamily: fontFamily)]),
initialState: const TextThemeState(),
);
await tester.pumpWidget(
RepositoryProvider(
create: (context) => FontRepository(),
child: BlocProvider.value(
value: cubit,
child: MaterialApp(
home: Scaffold(
body: FontPicker(
onChanged: cubit.fontFamilyChanged,
),
),
),
),
),
);
await tester.tap(find.byKey(const Key('fontPicker')));
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('fontPicker_$fontFamily')));
await tester.pumpAndSettle();
expect(find.text(fontFamily), findsOneWidget);
verify(() => cubit.fontFamilyChanged(FontData(fontFamily, style)));
});
}