From 3cc74fa69f9f0e14dd5cb9f6e12358e50c77564e Mon Sep 17 00:00:00 2001 From: dab246 Date: Wed, 3 Aug 2022 16:25:48 +0700 Subject: [PATCH] TF-786 Add unit-test for LinkifyHtml --- core/test/linkify_html_test.dart | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 core/test/linkify_html_test.dart diff --git a/core/test/linkify_html_test.dart b/core/test/linkify_html_test.dart new file mode 100644 index 000000000..629f00ee0 --- /dev/null +++ b/core/test/linkify_html_test.dart @@ -0,0 +1,46 @@ + +import 'package:core/utils/linkify_html.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('linkify_html test', () { + + final linkifyHtml = LinkifyHtml(); + + test( + 'generateLinkify should return url when input text contain http/https/ftp', + () async { + final htmlValidate = linkifyHtml.generateLinkify( + 'See at Hanoi' + ); + expect( + htmlValidate, + equals('See <https://linagora.com> at Hanoi')); + } + ); + + test( + 'generateLinkify should return www when input text contain www', + () async { + final htmlValidate = linkifyHtml.generateLinkify( + 'See www.google.com at Hanoi' + ); + expect( + htmlValidate, + equals('See www.google.com at Hanoi')); + } + ); + + test( + 'generateLinkify should return url when input text contain email address', + () async { + final htmlValidate = linkifyHtml.generateLinkify( + 'See tdvu@linagora.com at Hanoi' + ); + expect( + htmlValidate, + equals('See tdvu@linagora.com at Hanoi')); + } + ); + }); +} \ No newline at end of file