-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.ts
More file actions
31 lines (24 loc) 路 1.06 KB
/
Copy pathtest.ts
File metadata and controls
31 lines (24 loc) 路 1.06 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
import { default as test } from 'ava'
import { default as execa } from 'execa'
test('it generates a valid CNPJ', async (t) => {
const { stdout: generated } = await execa('./dist/index.js')
t.true(generated.length > 0)
const { stdout: validated } = await execa('./dist/index.js', ['-v', generated])
t.true(validated === 'true')
})
test('it generates a valid numbers-only CNPJ', async (t) => {
const { stdout: generated } = await execa('./dist/index.js', ['-n'])
t.false(/\.|-|\//.test(generated))
const { stdout: validated } = await execa('./dist/index.js', ['-v', generated])
t.true(validated === 'true')
})
test('it validates a given CNPJ', async (t) => {
const { stdout: valid } = await execa('./dist/index.js', ['-v', '29.709.817/0001-15'])
t.true(valid === 'true')
const { stdout: invalid } = await execa('./dist/index.js', ['-v', '29.709.817/0001-00'])
t.true(invalid === 'false')
})
test('it formats a given CNPJ', async (t) => {
const { stdout: formatted } = await execa('./dist/index.js', ['-f', '29709817000115'])
t.is(formatted, '29.709.817/0001-15')
})