fix(core): update
This commit is contained in:
33
test/test.ts
33
test/test.ts
@ -3,41 +3,40 @@ import { Subject } from 'rxjs';
|
||||
|
||||
import * as smartcli from '../ts/index.js';
|
||||
|
||||
let smartCliTestObject: smartcli.Smartcli;
|
||||
|
||||
tap.test('should create a new Smartcli', async () => {
|
||||
smartCliTestObject = new smartcli.Smartcli();
|
||||
const smartCliTestObject = new smartcli.Smartcli();
|
||||
expect(smartCliTestObject).toBeInstanceOf(smartcli.Smartcli);
|
||||
});
|
||||
|
||||
tap.test('should add an command', async () => {
|
||||
expect(smartCliTestObject.addCommand('awesome')).toBeInstanceOf(Subject);
|
||||
tap.test('should add an command', async (toolsArg) => {
|
||||
const done = toolsArg.defer();
|
||||
const smartCliTestObject = new smartcli.Smartcli();
|
||||
const awesomeCommandSubject = smartCliTestObject.addCommand('awesome')
|
||||
expect(awesomeCommandSubject).toBeInstanceOf(Subject);
|
||||
awesomeCommandSubject.subscribe(() => {
|
||||
done.resolve();
|
||||
});
|
||||
console.log(process.argv);
|
||||
process.argv.splice(2, 0, 'awesome');
|
||||
console.log(process.argv);
|
||||
smartCliTestObject.startParse();
|
||||
await done.promise;
|
||||
});
|
||||
|
||||
tap.test('should start parsing a standardTask', async () => {
|
||||
const smartCliTestObject = new smartcli.Smartcli();
|
||||
expect(smartCliTestObject.standardCommand()).toBeInstanceOf(Subject);
|
||||
});
|
||||
|
||||
let hasExecuted: boolean = false;
|
||||
|
||||
tap.test('should accept a command', async () => {
|
||||
const smartCliTestObject = new smartcli.Smartcli();
|
||||
smartCliTestObject.addCommand('triggerme').subscribe(() => {
|
||||
hasExecuted = true;
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should not have executed yet', async () => {
|
||||
expect(hasExecuted).toBeFalse();
|
||||
});
|
||||
|
||||
tap.test('should execute when triggered', async () => {
|
||||
smartCliTestObject.triggerCommand('triggerme', {});
|
||||
expect(hasExecuted).toBeTrue();
|
||||
});
|
||||
|
||||
tap.test('should start parsing the CLI input', async () => {
|
||||
smartCliTestObject.startParse();
|
||||
expect(smartCliTestObject.parseCompleted.promise).toBeInstanceOf(Promise);
|
||||
});
|
||||
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user