-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extend plugins + write tests for plugin api
- Loading branch information
1 parent
aa459a1
commit a283f15
Showing
3 changed files
with
41 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.cacheOnSave": true, | ||
"deno.lint": true, | ||
"[typescript]": { | ||
"editor.defaultFormatter": "denoland.vscode-deno" | ||
}, | ||
"editor.formatOnSave": true | ||
} | ||
} |
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ import { | |
spy, | ||
} from 'https://deno.land/[email protected]/testing/mock.ts' | ||
import { CLI } from './spektr.ts' | ||
import { Positionals } from './types.ts' | ||
import { Plugin, Positionals } from './types.ts' | ||
import { ParsedOptions } from './types.ts' | ||
|
||
describe('CLI', () => { | ||
|
@@ -318,4 +318,36 @@ describe('CLI', () => { | |
assertSpyCall(mwSpy, 0) | ||
}) | ||
}) | ||
describe('plugins', () => { | ||
it('should apply them', () => { | ||
const helpFnSpy = spy(() => `Plugin`) | ||
const myPlugin: Plugin = () => ({ | ||
helpFn: () => 'Help', | ||
helpMessage: helpFnSpy, | ||
}) | ||
|
||
const cli = new CLI({ plugins: [myPlugin] }) | ||
cli.help() | ||
|
||
cli.handle(['--help']) | ||
|
||
assertSpyCall(helpFnSpy, 0) | ||
}) | ||
it('should nest plugins', () => { | ||
const helpFnSpy = spy(() => `Plugin`) | ||
const myPlugin: Plugin = () => ({ | ||
helpFn: () => 'Help', | ||
helpMessage: helpFnSpy, | ||
}) | ||
|
||
const cli = new CLI({ plugins: [myPlugin] }) | ||
cli.help() | ||
|
||
cli.program('sub').help() | ||
|
||
cli.handle(['sub', '--help']) | ||
|
||
assertSpyCall(helpFnSpy, 0) | ||
}) | ||
}) | ||
}) |