diff --git a/core/test/linkify_html_test.dart b/core/test/linkify_html_test.dart deleted file mode 100644 index 00434a55f..000000000 --- a/core/test/linkify_html_test.dart +++ /dev/null @@ -1,59 +0,0 @@ - -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')); - } - ); - - test( - 'generateLinkify should preserve the text when input text contain james/ApacheJames/master [master] [765]"' - ); - expect( - htmlValidate, - equals('Check console output at "james/ApacheJames/master [master] [765]"') - ); - } - ); - }); -} \ No newline at end of file diff --git a/core/test/sanitize_autolink_filter_test.dart b/core/test/sanitize_autolink_filter_test.dart new file mode 100644 index 000000000..1c5e962bc --- /dev/null +++ b/core/test/sanitize_autolink_filter_test.dart @@ -0,0 +1,55 @@ +import 'dart:convert'; + +import 'package:core/presentation/utils/html_transformer/sanitize_autolink_filter.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('SanitizeAutolinkFilter test', () { + + final sanitizeAutolinkFilter = SanitizeAutolinkFilter(const HtmlEscape()); + + test( + 'SanitizeAutolinkFilter should return html a tag with href="urlLink" when input text contain https', + () { + final htmlValidate = sanitizeAutolinkFilter.process('See https://linagora.com at Hanoi'); + expect( + htmlValidate, + equals('See linagora.com at Hanoi') + ); + } + ); + + test( + 'SanitizeAutolinkFilter should return html a tag with href="urlLink" when input text contain http', + () { + final htmlValidate = sanitizeAutolinkFilter.process('See http://linagora.com at Hanoi'); + expect( + htmlValidate, + equals('See linagora.com at Hanoi') + ); + } + ); + + test( + 'SanitizeAutolinkFilter should return html a tag with href="urlLink" when input text contain www', + () { + final htmlValidate = sanitizeAutolinkFilter.process('See www.linagora.com at Hanoi'); + expect( + htmlValidate, + equals('See linagora.com at Hanoi') + ); + } + ); + + test( + 'SanitizeAutolinkFilter should return html a tag with href="mailToLink" when input text contain email address', + () { + final htmlValidate = sanitizeAutolinkFilter.process('See tdvu@linagora.com at Hanoi'); + expect( + htmlValidate, + equals('See tdvu@linagora.com at Hanoi') + ); + } + ); + }); +} \ No newline at end of file