forked from Alexander-Ordina/flutter_html_lite
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: a tag should not style as link if href is not provided (Sub6Reso…
- Loading branch information
1 parent
2ffa1dd
commit d7247cb
Showing
5 changed files
with
126 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_html/flutter_html.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
import '../test_data.dart'; | ||
|
||
void main() { | ||
testWidgets('<a> test', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """<a>Hello, world!</a>""", | ||
), | ||
), | ||
); | ||
expect(find.text("Hello, world!", findRichText: true), findsOneWidget); | ||
}); | ||
|
||
testWidgets('<a> test with href', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """<a href="https://example.com">Hello, world!</a>""", | ||
), | ||
), | ||
); | ||
expect(find.text("Hello, world!", findRichText: true), findsOneWidget); | ||
}); | ||
|
||
testWidgets('<a> with widget child renders', (WidgetTester tester) async { | ||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """<a href="https://example.com"><icon></icon></a>""", | ||
extensions: [ | ||
TagExtension( | ||
tagsToExtend: {"icon"}, | ||
child: const Icon(Icons.check), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
expect(find.byIcon(Icons.check), findsOneWidget); | ||
}); | ||
|
||
testWidgets('Tapping <a> test', (WidgetTester tester) async { | ||
String tappedUrl = ""; | ||
|
||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """<a href="https://example.com">Hello, world!</a>""", | ||
onLinkTap: (url, _, __) { | ||
tappedUrl = url ?? ""; | ||
}, | ||
), | ||
), | ||
); | ||
expect(find.text("Hello, world!", findRichText: true), findsOneWidget); | ||
expect(tappedUrl, equals("")); | ||
await tester.tap(find.text("Hello, world!", findRichText: true)); | ||
expect(tappedUrl, equals("https://example.com")); | ||
}); | ||
|
||
testWidgets('Tapping <a> with widget works', (WidgetTester tester) async { | ||
String tappedUrl = ""; | ||
|
||
await tester.pumpWidget( | ||
TestApp( | ||
child: Html( | ||
data: """<a href="https://example.com"><icon></icon></a>""", | ||
onLinkTap: (url, _, __) { | ||
tappedUrl = url ?? ""; | ||
}, | ||
extensions: [ | ||
TagExtension( | ||
tagsToExtend: {"icon"}, | ||
child: const Icon(Icons.check), | ||
), | ||
], | ||
), | ||
), | ||
); | ||
expect(find.byIcon(Icons.check), findsOneWidget); | ||
expect(tappedUrl, equals("")); | ||
await tester.tap(find.byIcon(Icons.check)); | ||
expect(tappedUrl, equals("https://example.com")); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters