Skip to content

Commit

Permalink
refactor: string flags
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Feb 7, 2023
1 parent dcf796b commit 3864220
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/parser/parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ See more help with --help`)
it('allowed options on multiple', async () => {
const out = await parse(['--foo', 'a', '--foo=b'], {
flags: {
foo: Flags.custom({multiple: true, parse: async i => i, options: ['a', 'b']})(),
foo: Flags.string({multiple: true, parse: async i => i, options: ['a', 'b']}),
},
})
expect(out.flags).to.deep.include({foo: ['a', 'b']})
Expand All @@ -364,7 +364,7 @@ See more help with --help`)
it('one of allowed options on multiple', async () => {
const out = await parse(['--foo', 'a'], {
flags: {
foo: Flags.custom({multiple: true, parse: async i => i, options: ['a', 'b']})(),
foo: Flags.string({multiple: true, options: ['a', 'b']}),
},
})
expect(out.flags).to.deep.include({foo: ['a']})
Expand All @@ -373,7 +373,7 @@ See more help with --help`)
try {
await parse(['--foo', 'a', '--foo=c'], {
flags: {
foo: Flags.custom({multiple: true, parse: async i => i, options: ['a', 'b']})(),
foo: Flags.string({multiple: true, options: ['a', 'b']}),
},
})
} catch (error:any) {
Expand All @@ -384,23 +384,23 @@ See more help with --help`)
it('basic', async () => {
const out = await parse(['--foo', 'a,b'], {
flags: {
foo: Flags.custom({multiple: true, delimiter: ',', parse: async i => i})(),
foo: Flags.string({multiple: true, delimiter: ','}),
},
})
expect(out.flags).to.deep.include({foo: ['a', 'b']})
})
it('with spaces inside quotes', async () => {
const out = await parse(['--foo', '"a a","b b"'], {
flags: {
foo: Flags.custom({multiple: true, delimiter: ',', parse: async i => i})(),
foo: Flags.string({multiple: true, delimiter: ','}),
},
})
expect(out.flags).to.deep.include({foo: ['a a', 'b b']})
})
it('with options', async () => {
const out = await parse(['--foo', 'a,b'], {
flags: {
foo: Flags.custom({multiple: true, delimiter: ',', parse: async i => i, options: ['a', 'b']})(),
foo: Flags.string({multiple: true, delimiter: ',', options: ['a', 'b']}),
},
})
expect(out.flags).to.deep.include({foo: ['a', 'b']})
Expand All @@ -409,7 +409,7 @@ See more help with --help`)
try {
await parse(['--foo', 'a,c'], {
flags: {
foo: Flags.custom({multiple: true, parse: async i => i, options: ['a', 'b']})(),
foo: Flags.string({multiple: true, options: ['a', 'b']}),
},
})
} catch (error:any) {
Expand All @@ -420,7 +420,7 @@ See more help with --help`)
it('with options and quotes with spaces', async () => {
const out = await parse(['--foo', '"a a","b b"'], {
flags: {
foo: Flags.custom({multiple: true, delimiter: ',', parse: async i => i, options: ['a a', 'b b']})(),
foo: Flags.string({multiple: true, delimiter: ',', options: ['a a', 'b b']}),
},
})
expect(out.flags).to.deep.include({foo: ['a a', 'b b']})
Expand All @@ -429,7 +429,7 @@ See more help with --help`)
try {
await parse(['--foo', '"a a","b c"'], {
flags: {
foo: Flags.custom({multiple: true, delimiter: ',', parse: async i => i, options: ['a a', 'b b']})(),
foo: Flags.string({multiple: true, delimiter: ',', options: ['a a', 'b b']}),
},
})
} catch (error:any) {
Expand Down

0 comments on commit 3864220

Please sign in to comment.