Skip to content

Commit

Permalink
Update parseArgs tests (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
askoufis authored Mar 21, 2024
1 parent fda0952 commit ba918f5
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions packages/sku/lib/parseArgs.test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
const parseArgs = require('./parseArgs');

describe('arg parsing', () => {
test('sku exec', () => {
const { script, argv, env } = parseArgs([
describe('parseArgs', () => {
test('sku script with short and long flag', () => {
const { script, argv, env, config } = parseArgs([
'/path/to/node',
'/path/to/bin/sku',
'lint',
'-e',
'test',
'--config',
'custom.sku.config.ts',
]);

expect(script).toEqual('lint');
expect(argv).toEqual([]);
expect(env).toEqual('test');
expect(config).toEqual('custom.sku.config.ts');
});

test('sku exec with args', () => {
test('sku script with flag and argument', () => {
const { script, argv, env } = parseArgs([
'/path/to/node',
'/path/to/bin/sku',
Expand All @@ -23,11 +27,28 @@ describe('arg parsing', () => {
'-e',
'test',
]);

expect(script).toEqual('lint');
expect(argv).toEqual(['src/components/**']);
expect(env).toEqual('test');
});

test('sku script with argument, known flag and unknown flag', () => {
const { script, argv, env } = parseArgs([
'/path/to/node',
'/path/to/bin/sku',
'test',
'-e',
'test',
'testFilter',
'--someJestFlag',
]);

expect(script).toEqual('test');
expect(argv).toEqual(['testFilter', '--someJestFlag']);
expect(env).toEqual('test');
});

test('debug', () => {
expect(
parseArgs(['/path/to/node', '/path/to/bin/sku', 'build']).debug,
Expand Down

0 comments on commit ba918f5

Please sign in to comment.