forked from netlify/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse-raw-flags.test.js
More file actions
42 lines (37 loc) · 1008 Bytes
/
Copy pathparse-raw-flags.test.js
File metadata and controls
42 lines (37 loc) · 1008 Bytes
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
const test = require('ava')
const { parseRawFlags, aggressiveJSONParse } = require('./parse-raw-flags')
test.serial('JSONTruthy works with various inputs', async t => {
const testPairs = [
{
input: 'true',
wanted: true,
},
{
input: 'false',
wanted: false,
},
{
input: JSON.stringify({ foo: 'bar' }),
wanted: { foo: 'bar' },
},
{
input: 'Hello-world 1234',
wanted: 'Hello-world 1234',
},
]
testPairs.forEach(pair => {
t.deepEqual(aggressiveJSONParse(pair.input), pair.wanted)
})
})
test.serial('parseRawFlags works', async t => {
const input = [
{ type: 'arg', input: 'FAUNA' },
{ type: 'arg', input: 'FOO' },
{ type: 'arg', input: 'BAR' },
{ type: 'arg', input: '--hey' },
{ type: 'arg', input: 'hi' },
{ type: 'arg', input: '--heep' },
]
const expected = { hey: 'hi', heep: true }
t.deepEqual(parseRawFlags(input), expected, 'parse raw flag parses flags in an expected way')
})