Skip to content
Prev Previous commit
Next Next commit
[flutter_markdown] test for custom font feature
  • Loading branch information
dawidope committed Jan 11, 2024
commit e723138e3cc3e82ee932ee42687514b8764e1869
31 changes: 30 additions & 1 deletion packages/flutter_markdown/test/footnote_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void defineTests() {
'superscript textstyle replacing',
() {
testWidgets(
'superscript has correct fontfeature',
'superscript has correct default fontfeature',
(WidgetTester tester) async {
const String data = 'Foo[^a]\n[^a]: Bar';
await tester.pumpWidget(
Expand All @@ -184,6 +184,35 @@ void defineTests() {
},
);

testWidgets(
'superscript has correct custom fontfeature',
(WidgetTester tester) async {
const String data = 'Foo[^a]\n[^a]: Bar';
await tester.pumpWidget(
boilerplate(
MarkdownBody(
data: data,
styleSheet:
MarkdownStyleSheet(superscriptFontFeatureTag: 'numr'),
),
),
);

final Iterable<Widget> widgets = tester.allWidgets;
final RichText richText = widgets
.firstWhere((Widget widget) => widget is RichText) as RichText;

final TextSpan span = richText.text as TextSpan;
final List<InlineSpan>? children = span.children;

expect(children, isNotNull);
expect(children!.length, 2);
expect(children[1].style, isNotNull);
expect(children[1].style!.fontFeatures?.length, 2);
expect(children[1].style!.fontFeatures?[1].feature, 'numr');
},
);

testWidgets(
'superscript index has the same font style like text',
(WidgetTester tester) async {
Expand Down