[flutter_markdown] fix for latest pkg:markdown part 2 (#2797)

This commit is contained in:
Zhiguang Chen
2022-11-10 20:20:30 +01:00
committed by GitHub
parent 4cb9b29a74
commit 84a8fe07fe
3 changed files with 53 additions and 16 deletions

View File

@ -6,6 +6,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_test/flutter_test.dart';
import 'utils.dart';
void main() => defineTests();
@ -628,7 +629,13 @@ void defineTests() {
);
expectValidLink('link');
expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo\bar'));
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo\bar'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap(linkTapResults, const MarkdownLink('link', 'foo%08ar'));
}
},
);
@ -649,8 +656,15 @@ void defineTests() {
);
expectValidLink('link');
expectLinkTap(
linkTapResults, const MarkdownLink('link', 'foo%20b&auml;'));
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(
linkTapResults, const MarkdownLink('link', 'foo%20b&auml;'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap(
linkTapResults, const MarkdownLink('link', 'foo%20b%C3%A4'));
}
},
);
@ -759,8 +773,15 @@ void defineTests() {
);
expectValidLink('link');
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url', 'title %22&quot;'));
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url', 'title %22&quot;'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url', 'title &quot;&quot;'));
}
},
);
@ -781,8 +802,15 @@ void defineTests() {
);
expectValidLink('link');
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url\u{C2A0}%22title%22'));
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url\u{C2A0}%22title%22'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url%EC%8A%A0%22title%22'));
}
},
);
@ -825,8 +853,17 @@ void defineTests() {
);
expectValidLink('link');
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url', 'title %22and%22 title'));
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expectLinkTap(linkTapResults,
const MarkdownLink('link', '/url', 'title %22and%22 title'));
} else {
// For pkg:markdown > v6.0.1
expectLinkTap(
linkTapResults,
const MarkdownLink('link', '/url', 'title &quot;and&quot; title'),
);
}
},
);

View File

@ -5,13 +5,9 @@
import 'package:flutter/material.dart';
import 'package:flutter_markdown/flutter_markdown.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:markdown/markdown.dart' as md show version;
import 'utils.dart';
// TODO(kevmoo): delete this once the min version of pkg:markdown is updated
final bool _newMarkdown = md.version.compareTo('6.0.1') > 0;
void main() => defineTests();
void defineTests() {
@ -395,7 +391,7 @@ void defineTests() {
expectTableSize(3, 2);
if (!_newMarkdown) {
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expect(find.byType(RichText), findsNWidgets(6));
final List<String?> text = find
@ -464,7 +460,7 @@ void defineTests() {
.toList();
expect(text[0], '| abc | def | | --- | | bar |');
},
skip: !_newMarkdown,
skip: !newMarkdown,
);
testWidgets(
@ -489,7 +485,7 @@ void defineTests() {
expectTableSize(3, 2);
if (!_newMarkdown) {
if (!newMarkdown) {
// For pkg:markdown <= v6.0.1
expect(find.byType(RichText), findsNWidgets(5));
final List<String?> cellText = find

View File

@ -9,6 +9,10 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:markdown/markdown.dart' as md show version;
// TODO(Zhiguang): delete this once the min version of pkg:markdown is updated
final bool newMarkdown = md.version.compareTo('6.0.1') > 0;
final TextTheme textTheme = Typography.material2018()
.black