From 23546b55188a01975ffa13a61425aad6f0b2331f Mon Sep 17 00:00:00 2001 From: dab246 Date: Thu, 25 Jan 2024 08:58:27 +0700 Subject: [PATCH] TF-2492 Write unit test `removeCollapsedSignatureEffect` method Signed-off-by: dab246 --- ..._test.dart => image_transformer_test.dart} | 0 ...emove_collapsed_signature_effect_test.dart | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+) rename core/test/utils/{html_utils_test.dart => image_transformer_test.dart} (100%) create mode 100644 core/test/utils/remove_collapsed_signature_effect_test.dart diff --git a/core/test/utils/html_utils_test.dart b/core/test/utils/image_transformer_test.dart similarity index 100% rename from core/test/utils/html_utils_test.dart rename to core/test/utils/image_transformer_test.dart diff --git a/core/test/utils/remove_collapsed_signature_effect_test.dart b/core/test/utils/remove_collapsed_signature_effect_test.dart new file mode 100644 index 0000000000..50e9e9cc05 --- /dev/null +++ b/core/test/utils/remove_collapsed_signature_effect_test.dart @@ -0,0 +1,33 @@ +import 'package:core/presentation/utils/html_transformer/html_utils.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + group('removeCollapsedSignatureEffect test', () { + test('RemoveCollapsedSignatureEffect should remove all signature html tags when content CONTAIN ONE tag with attribute class is `tmail-signature-button`', () async { + String originContent = '

Hello dab

Signature
Content
'; + String expectedContent = '

Hello dab

Content
'; + + String actualContent = await HtmlUtils.removeCollapsedSignatureEffect(originContent); + + expect(actualContent, expectedContent); + }); + + test('RemoveCollapsedSignatureEffect should remove all signature html tags when content CONTAIN MULTIPLE tag with attribute class is `tmail-signature-button`', () async { + String originContent = '

Hello dab

Signature 1
Content 1
Signature 2
Content 2
'; + String expectedContent = '

Hello dab

Content 1
Content 2
'; + + String actualContent = await HtmlUtils.removeCollapsedSignatureEffect(originContent); + + expect(actualContent, expectedContent); + }); + + test('RemoveCollapsedSignatureEffect should be return origin content when content NOT CONTAIN tag with attribute class is `tmail-signature-button`', () async { + String originContent = '

Hello dab

Content
'; + String expectedContent = '

Hello dab

Content
'; + + String actualContent = await HtmlUtils.removeCollapsedSignatureEffect(originContent); + + expect(actualContent, expectedContent); + }); + }); +} \ No newline at end of file