Skip to content

Commit

Permalink
test(flags): add value test
Browse files Browse the repository at this point in the history
  • Loading branch information
c4spar committed Apr 4, 2020
1 parent 2fbfd54 commit 6e3bc57
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/flags/test/option/value_test.ts
@@ -0,0 +1,29 @@
import { parseFlags } from '../../lib/flags.ts';
import { IParseOptions } from '../../lib/types.ts';
import { assertEquals } from '../lib/assert.ts';

const options = <IParseOptions>{
stopEarly: false,
allowEmpty: false,
flags: [ {
name: 'flag',
aliases: [ 'f' ],
value( value: string ): string[] {
return [ value ];
}
}, {
name: 'flag2',
aliases: [ 'F' ]
} ]
};

Deno.test( function flags_optionVariadic_optional() {

const { flags, unknown, literal } = parseFlags( [ '-f', '1', '-F', '1' ], options );

assertEquals( flags, { flag: [ '1' ], flag2: '1' } );
assertEquals( unknown, [] );
assertEquals( literal, [] );
} );

await Deno.runTests();

0 comments on commit 6e3bc57

Please sign in to comment.