-
-
Notifications
You must be signed in to change notification settings - Fork 901
/
Copy pathgolden_test.dart
76 lines (63 loc) · 1.78 KB
/
golden_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
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_test/flutter_test.dart';
import 'test_utils.dart';
class TestApp extends StatelessWidget {
final Widget body;
const TestApp(this.body, {super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: body,
),
);
}
}
void testHtml(String name, String htmlData) {
testWidgets('$name golden test', (WidgetTester tester) async {
await tester.pumpWidget(
TestApp(
Html(
data: htmlData,
),
),
);
expect(find.byType(Html), findsOneWidget);
// await expectLater(find.byType(Html), matchesGoldenFile('./goldens/$name.png'));
});
}
void main() {
//Test each HTML element
testData.forEach((key, value) {
testHtml(key, value);
});
//Test whitespace processing:
testWidgets('whitespace golden test', (WidgetTester tester) async {
await tester.pumpWidget(
TestApp(
Html(data: """
<p id='whitespace'>
These two lines should have an identical length:<br /><br />
The quick <b> brown </b><u><i> fox </i></u> jumped over the
lazy
dog.<br />
The quick brown fox jumped over the lazy dog.
</p>
"""),
),
);
// await expectLater(find.byType(Html), matchesGoldenFile('./goldens/whitespace.png'));
});
testWidgets('whitespace between inline elements golden test',
(WidgetTester tester) async {
await tester.pumpWidget(
TestApp(
Html(
data: """<b>Harry</b> <b>Potter</b>""",
),
),
);
// await expectLater(find.byType(Html), matchesGoldenFile('./goldens/whitespace_btwn_inline.png'));
});
}