forked from simc/auto_size_text
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbasic_test.dart
95 lines (86 loc) · 2.29 KB
/
basic_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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'utils.dart';
void main() {
testWidgets('Only Text', (tester) async {
await pump(
tester: tester,
widget: AutoSizeText('Some Text'),
);
});
testWidgets('Only text (rich)', (tester) async {
await pump(
tester: tester,
widget: AutoSizeText.rich(TextSpan(text: 'Some Text')),
);
});
testWidgets('Uses style fontSize', (tester) async {
await pumpAndExpectFontSize(
tester: tester,
expectedFontSize: 34,
widget: AutoSizeText(
'Some Text',
style: TextStyle(fontSize: 34),
),
);
});
testWidgets('Uses style fontSize (rich)', (tester) async {
await pumpAndExpectFontSize(
tester: tester,
expectedFontSize: 35,
widget: AutoSizeText.rich(
TextSpan(text: 'Some Text'),
style: TextStyle(fontSize: 35),
),
);
});
testWidgets('Respects inherit style', (tester) async {
final defaultStyle = TextStyle(
fontSize: 20,
color: Colors.yellow,
);
final text = await pumpAndGetText(
tester: tester,
widget: DefaultTextStyle(
style: defaultStyle,
textAlign: TextAlign.right,
softWrap: false,
overflow: TextOverflow.ellipsis,
maxLines: 17,
child: AutoSizeText(
'AutoSizeText Test',
),
),
);
expect(text.style, defaultStyle);
final richText = getRichText(tester);
expect(richText.textAlign, TextAlign.right);
expect(richText.softWrap, false);
expect(richText.overflow, TextOverflow.ellipsis);
expect(richText.maxLines, 17);
});
testWidgets('Applies scale even if initial fontSize fits (#25)',
(tester) async {
await pumpAndExpectFontSize(
tester: tester,
expectedFontSize: 60,
widget: AutoSizeText(
'Some Text',
style: TextStyle(fontSize: 15),
textScaleFactor: 4,
),
);
});
testWidgets('Uses textKey', (tester) async {
final textKey = GlobalKey();
final text = await pumpAndGetText(
tester: tester,
widget: AutoSizeText(
'A text with key',
textKey: textKey,
),
);
expect(text.key, textKey);
});
}