Skip to content

Commit 51208c9

Browse files
committed
add test
1 parent f2b1c63 commit 51208c9

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import 'package:flutter_test/flutter_test.dart';
2+
3+
import 'package:emailjs/emailjs.dart';
4+
import 'package:emailjs/src/utils/is_blocked_value_in_params.dart';
5+
6+
void main() {
7+
group('should be disabled', () {
8+
test('get value', () {
9+
const blockList = BlockList();
10+
expect(isBlockedValueInParams(blockList, {}), false);
11+
});
12+
13+
test('without list', () {
14+
const blockList = BlockList(watchVariable: 'email');
15+
expect(isBlockedValueInParams(blockList, {}), false);
16+
});
17+
18+
test('without watchVariable', () {
19+
const blockList = BlockList(list: ['test@emailjs.com']);
20+
expect(isBlockedValueInParams(blockList, {}), false);
21+
});
22+
23+
test('without data', () {
24+
const blockList = BlockList(
25+
watchVariable: 'email',
26+
list: ['test@emailjs.com'],
27+
);
28+
29+
expect(isBlockedValueInParams(blockList, {}), false);
30+
});
31+
32+
test('wrong type', () {
33+
const blockList = BlockList(
34+
watchVariable: 'email',
35+
list: ['test@emailjs.com'],
36+
);
37+
38+
expect(isBlockedValueInParams(blockList, {
39+
'email': ['item', 'item'],
40+
}), false);
41+
});
42+
43+
test('not found in the list', () {
44+
const blockList = BlockList(
45+
watchVariable: 'email',
46+
list: ['test@emailjs.com', 'bar@emailjs.com'],
47+
);
48+
49+
expect(isBlockedValueInParams(blockList, {
50+
'email': 'foo@emailjs.com',
51+
}), false);
52+
});
53+
});
54+
55+
group('should be enabled', () {
56+
test('template params', () {
57+
const blockList = BlockList(
58+
watchVariable: 'email',
59+
list: ['test@emailjs.com', 'foo@emailjs.com', 'bar@emailjs.com'],
60+
);
61+
62+
expect(isBlockedValueInParams(blockList, {
63+
'email': 'test@emailjs.com',
64+
'other': 'other data',
65+
}), true);
66+
});
67+
});
68+
}

0 commit comments

Comments
 (0)