2018-08-30 22:13:05 +00:00
|
|
|
import { tap, expect } from '@pushrocks/tapbundle';
|
2018-05-03 10:10:39 +00:00
|
|
|
import { Subject } from 'rxjs';
|
2016-06-10 00:27:04 +00:00
|
|
|
|
2022-08-03 15:00:36 +00:00
|
|
|
import * as smartcli from '../ts/index.js';
|
2017-04-22 19:03:28 +00:00
|
|
|
|
|
|
|
tap.test('should create a new Smartcli', async () => {
|
2022-08-03 16:47:35 +00:00
|
|
|
const smartCliTestObject = new smartcli.Smartcli();
|
2022-08-03 15:00:36 +00:00
|
|
|
expect(smartCliTestObject).toBeInstanceOf(smartcli.Smartcli);
|
2018-05-03 10:10:39 +00:00
|
|
|
});
|
2017-04-22 19:03:28 +00:00
|
|
|
|
2022-08-03 16:47:35 +00:00
|
|
|
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;
|
2018-05-03 10:10:39 +00:00
|
|
|
});
|
2017-04-22 19:03:28 +00:00
|
|
|
|
|
|
|
tap.test('should start parsing a standardTask', async () => {
|
2022-08-03 16:47:35 +00:00
|
|
|
const smartCliTestObject = new smartcli.Smartcli();
|
2022-08-03 15:00:36 +00:00
|
|
|
expect(smartCliTestObject.standardCommand()).toBeInstanceOf(Subject);
|
2018-05-03 10:10:39 +00:00
|
|
|
});
|
2017-04-22 19:03:28 +00:00
|
|
|
|
2018-05-03 10:10:39 +00:00
|
|
|
let hasExecuted: boolean = false;
|
2017-04-22 21:16:49 +00:00
|
|
|
|
2017-04-22 19:03:28 +00:00
|
|
|
tap.test('should accept a command', async () => {
|
2022-08-03 16:47:35 +00:00
|
|
|
const smartCliTestObject = new smartcli.Smartcli();
|
2022-08-03 15:00:36 +00:00
|
|
|
smartCliTestObject.addCommand('triggerme').subscribe(() => {
|
2018-05-03 10:10:39 +00:00
|
|
|
hasExecuted = true;
|
|
|
|
});
|
2022-08-03 15:00:36 +00:00
|
|
|
smartCliTestObject.triggerCommand('triggerme', {});
|
|
|
|
expect(hasExecuted).toBeTrue();
|
2018-05-03 10:10:39 +00:00
|
|
|
});
|
2017-04-22 19:03:28 +00:00
|
|
|
|
2018-05-03 10:10:39 +00:00
|
|
|
tap.start();
|