Skip to content

Commit

Permalink
TF-2492 Write unit test removeCollapsedSignatureEffect method
Browse files Browse the repository at this point in the history
Signed-off-by: dab246 <[email protected]>
  • Loading branch information
dab246 authored and hoangdat committed Jan 25, 2024
1 parent 68af0e7 commit 23546b5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
File renamed without changes.
33 changes: 33 additions & 0 deletions core/test/utils/remove_collapsed_signature_effect_test.dart
Original file line number Diff line number Diff line change
@@ -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 = '<p>Hello dab</p><div class="tmail-signature"><div class="tmail-signature-button">Signature</div><div class="tmail-signature-content">Content</div></div>';
String expectedContent = '<p>Hello dab</p><div class="tmail-signature"><div class="tmail-signature-content">Content</div></div>';

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 = '<p>Hello dab</p><div class="tmail-signature"><div class="tmail-signature-button">Signature 1</div><div class="tmail-signature-content">Content 1</div></div><div class="tmail-signature"><div class="tmail-signature-button">Signature 2</div><div class="tmail-signature-content">Content 2</div></div>';
String expectedContent = '<p>Hello dab</p><div class="tmail-signature"><div class="tmail-signature-content">Content 1</div></div><div class="tmail-signature"><div class="tmail-signature-content">Content 2</div></div>';

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 = '<p>Hello dab</p><div class="tmail-signature"><div class="tmail-signature-content">Content</div></div>';
String expectedContent = '<p>Hello dab</p><div class="tmail-signature"><div class="tmail-signature-content">Content</div></div>';

String actualContent = await HtmlUtils.removeCollapsedSignatureEffect(originContent);

expect(actualContent, expectedContent);
});
});
}

0 comments on commit 23546b5

Please sign in to comment.