43 lines
1.4 KiB
TypeScript
43 lines
1.4 KiB
TypeScript
import { tap, expect } from '@push.rocks/tapbundle';
|
|
import * as smartrx from '@push.rocks/smartrx';
|
|
|
|
import * as smartcli from '../ts/index.js';
|
|
|
|
tap.test('should create a new Smartcli', async () => {
|
|
const smartCliTestObject = new smartcli.Smartcli();
|
|
expect(smartCliTestObject).toBeInstanceOf(smartcli.Smartcli);
|
|
});
|
|
|
|
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(smartrx.rxjs.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(smartrx.rxjs.Subject);
|
|
});
|
|
|
|
let hasExecuted: boolean = false;
|
|
|
|
tap.test('should accept a command', async () => {
|
|
const smartCliTestObject = new smartcli.Smartcli();
|
|
smartCliTestObject.addCommand('triggerme').subscribe(() => {
|
|
hasExecuted = true;
|
|
});
|
|
smartCliTestObject.triggerCommand('triggerme', {});
|
|
expect(hasExecuted).toBeTrue();
|
|
});
|
|
|
|
tap.start();
|