-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app-builder): allow exempting commands from root command logic
- Loading branch information
1 parent
3d6e039
commit d103a2d
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import {describe, expect, it} from 'vitest'; | ||
import {createTestContext} from '../__tests__/createTestContext'; | ||
import {createCommand} from './createCommand'; | ||
|
||
describe('createCommand', () => { | ||
it.each([ | ||
['foo', 'foo'], | ||
['foo bar', 'foo bar'], | ||
[['foo'], 'foo'], | ||
[['foo', 'bar'], 'foo bar'], | ||
[['foo', 'bar', 'baz'], 'foo bar baz'], | ||
])('should return the command as a string', (command, expected) => { | ||
const context = createTestContext(); | ||
|
||
expect(createCommand(context.config, command)).toEqual(expected); | ||
}); | ||
|
||
it('should prepend the command with the root command', () => { | ||
const context = createTestContext({ | ||
config: { | ||
rootCommand: 'root command', | ||
rootCommands: ['foo'], | ||
}, | ||
}); | ||
|
||
expect(createCommand(context.config, 'foo')).toEqual('root command foo'); | ||
}); | ||
|
||
it('should not prepend the command with the root command when the command is not in the rootCommands array', () => { | ||
const context = createTestContext({ | ||
config: { | ||
rootCommand: 'root command', | ||
rootCommands: [], | ||
}, | ||
}); | ||
|
||
expect(createCommand(context.config, 'bar')).toEqual('bar'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters