style_test.dart
2.29 KB
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
import 'dart:ui';
import 'package:flutter_math_fork/ast.dart';
import 'package:flutter_math_fork/src/parser/tex/font.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter_math_fork/src/encoder/tex/encoder.dart';
void main() {
group('style encoding test', () {
test('math style handling', () {
expect(
StyleNode(
optionsDiff: OptionsDiff(style: MathStyle.display),
children: [SymbolNode(symbol: 'a')],
).encodeTeX(),
'{\\displaystyle a}',
);
});
test('size handling', () {
expect(
StyleNode(
optionsDiff: OptionsDiff(size: MathSize.scriptsize),
children: [SymbolNode(symbol: 'a')],
).encodeTeX(),
'{\\scriptsize a}',
);
});
test('font handling', () {
expect(
StyleNode(
optionsDiff:
OptionsDiff(mathFontOptions: texMathFontOptions['\\mathbf']),
children: [SymbolNode(symbol: 'a')],
).encodeTeX(),
'\\mathbf{a}',
);
expect(
StyleNode(
optionsDiff:
OptionsDiff(textFontOptions: texTextFontOptions['\\textbf']),
children: [SymbolNode(symbol: 'a', mode: Mode.text)],
).encodeTeX(),
'\\textbf{a}',
);
});
test('color handling', () {
expect(
StyleNode(
optionsDiff: OptionsDiff(color: Color.fromARGB(0, 1, 2, 3)),
children: [SymbolNode(symbol: 'a')],
).encodeTeX(),
'\\textcolor{#010203}{a}',
);
});
test('avoid extra brackets', () {
expect(
StyleNode(
optionsDiff: OptionsDiff(
style: MathStyle.display,
size: MathSize.scriptsize,
color: Color.fromARGB(0, 1, 2, 3),
),
children: [SymbolNode(symbol: 'a')],
).encodeTeX(),
'\\textcolor{#010203}{\\displaystyle \\scriptsize a}',
);
expect(
EquationRowNode(children: [
SymbolNode(symbol: 'z'),
StyleNode(
optionsDiff: OptionsDiff(
style: MathStyle.display,
size: MathSize.scriptsize,
),
children: [SymbolNode(symbol: 'a')],
),
]).encodeTeX(),
'{z\\displaystyle \\scriptsize a}',
);
});
});
}