-
Notifications
You must be signed in to change notification settings - Fork 87
/
index.test.js
80 lines (72 loc) · 1.78 KB
/
index.test.js
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// @ts-check
const generatePayload = require('./')
/* eslint-env jest */
/**
* @param {string} name
* @param {string} id
* @param {generatePayload.Options} options
* @param {string} expected
*/
function testcase (name, id, options, expected) {
test(`${name}: ${id} ${require('util').inspect(options)} => ${expected}`, () => {
expect(generatePayload(id, options)).toBe(expected)
})
}
describe('Phone number', () => {
testcase(
'Local phone number',
'0801234567',
{ },
'00020101021129370016A000000677010111011300668012345675802TH530376463046197'
)
testcase(
'Dashed local phone number',
'080-123-4567',
{ },
'00020101021129370016A000000677010111011300668012345675802TH530376463046197'
)
testcase(
'Dashed phone number',
'+66-89-123-4567',
{ },
'00020101021129370016A000000677010111011300668912345675802TH5303764630429C1'
)
})
describe('National ID number', () => {
testcase(
'National ID number',
'1111111111111',
{ },
'00020101021129370016A000000677010111021311111111111115802TH530376463047B5A'
)
testcase(
'Dashed national ID number',
'1-1111-11111-11-1',
{ },
'00020101021129370016A000000677010111021311111111111115802TH530376463047B5A'
)
})
describe('Tax ID', () => {
testcase(
'Tax ID number',
'0123456789012',
{ },
'00020101021129370016A000000677010111021301234567890125802TH530376463040CBD'
)
})
describe('eWallet ID', () => {
testcase(
'eWallet ID',
'012345678901234',
{ },
'00020101021129390016A00000067701011103150123456789012345802TH530376463049781'
)
})
describe('Amount setting', () => {
testcase(
'Amount',
'000-000-0000',
{ amount: 4.22 },
'00020101021229370016A000000677010111011300660000000005802TH530376454044.226304E469'
)
})