Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 46 additions & 9 deletions packages/flutter_markdown/test/link_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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'));
}
},
);

Expand All @@ -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'));
}
},
);

Expand Down Expand Up @@ -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;'));
}
},
);

Expand All @@ -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'));
}
},
);

Expand Down Expand Up @@ -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'),
);
}
},
);

Expand Down
10 changes: 3 additions & 7 deletions packages/flutter_markdown/test/table_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -464,7 +460,7 @@ void defineTests() {
.toList();
expect(text[0], '| abc | def | | --- | | bar |');
},
skip: !_newMarkdown,
skip: !newMarkdown,
);

testWidgets(
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions packages/flutter_markdown/test/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down