forked from validatorjs/validator.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisISO31661Alpha3.test.js
More file actions
64 lines (59 loc) · 1.55 KB
/
isISO31661Alpha3.test.js
File metadata and controls
64 lines (59 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import test from '../testFunctions';
describe('isISO31661Alpha3', () => {
it('should validate ISO 3166-1 alpha 3 country codes', () => {
// from https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
test({
validator: 'isISO31661Alpha3',
valid: [
'ABW',
'HND',
'KHM',
'RWA',
],
invalid: [
'',
'FR',
'fR',
'GB',
'PT',
'CM',
'JP',
'PM',
'ZW',
'XXK',
],
});
});
it('should validate user assigned ISO 3166-1 alpha 3 code if provided', () => {
test({
validator: 'isISO31661Alpha3',
args: [{ userAssignedCodes: ['XXK', 'xxl'] }],
valid: ['BEL', 'FRA', 'GBR', 'USA', 'XXK', 'XXL'],
invalid: ['XXA', 'GGG'],
});
});
it('should not validate user assigned ISO 3166-1 alpha 3 not valid code if provided', () => {
test({
validator: 'isISO31661Alpha3',
args: [{ userAssignedCodes: ['', 'x', 'XX', 'XXXX'] }],
valid: ['FRA'],
invalid: ['XX', 'XXXX', 'X'],
});
});
it('should still validate ISO 3166-1 alpha 3 country codes if the options object is empty', () => {
test({
validator: 'isISO31661Alpha3',
args: [{}],
valid: ['FRA', 'USA'],
invalid: ['XXK'],
});
});
it('should still validate ISO 3166-1 alpha 3 country codes if the userAssignedCodes option is empty', () => {
test({
validator: 'isISO31661Alpha3',
args: [{ userAssignedCodes: [] }],
valid: ['FRA', 'USA'],
invalid: ['XXK'],
});
});
});