-
-
Notifications
You must be signed in to change notification settings - Fork 901
/
Copy pathhtml_parser_test.dart
54 lines (47 loc) · 1.35 KB
/
html_parser_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
import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets("Check that default parser does not fail on empty data",
(tester) async {
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Html(
data: "",
),
),
),
);
});
testWidgets('Test new parser (hacky workaround to get BuildContext)',
(WidgetTester tester) async {
await tester.pumpWidget(
Builder(
builder: (BuildContext context) {
testNewParser(context);
// The builder function must return a widget.
return const Placeholder();
},
),
);
});
}
void testNewParser(BuildContext context) {
HtmlParser.parseHTML("<b>Hello, World!</b>");
Style style1 = Style(
display: Display.block,
fontWeight: FontWeight.bold,
);
Style style2 = Style(
before: "* ",
direction: TextDirection.rtl,
fontStyle: FontStyle.italic,
);
Style finalStyle = style1.merge(style2);
expect(finalStyle.display, equals(Display.block));
expect(finalStyle.before, equals("* "));
expect(finalStyle.direction, equals(TextDirection.rtl));
expect(finalStyle.fontStyle, equals(FontStyle.italic));
expect(finalStyle.fontWeight, equals(FontWeight.bold));
}