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
|
|
|
|
2018-05-03 10:10:39 +00:00
|
|
|
let smartCliTestObject: smartcli.Smartcli;
|
2017-04-22 19:03:28 +00:00
|
|
|
|
|
|
|
tap.test('should create a new Smartcli', async () => {
|
2018-05-03 10:10:39 +00:00
|
|
|
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
|
|
|
|
|
|
|
tap.test('should add an command', async () => {
|
2022-08-03 15:00:36 +00:00
|
|
|
expect(smartCliTestObject.addCommand('awesome')).toBeInstanceOf(Subject);
|
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 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 15:00:36 +00:00
|
|
|
smartCliTestObject.addCommand('triggerme').subscribe(() => {
|
2018-05-03 10:10:39 +00:00
|
|
|
hasExecuted = true;
|
|
|
|
});
|
|
|
|
});
|
2017-04-22 20:09:51 +00:00
|
|
|
|
2017-04-22 19:03:28 +00:00
|
|
|
tap.test('should not have executed yet', async () => {
|
2022-08-03 15:00:36 +00:00
|
|
|
expect(hasExecuted).toBeFalse();
|
2018-05-03 10:10:39 +00:00
|
|
|
});
|
2017-04-22 20:09:51 +00:00
|
|
|
|
2017-04-22 19:03:28 +00:00
|
|
|
tap.test('should execute when triggered', async () => {
|
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
|
|
|
|
2017-04-23 13:21:08 +00:00
|
|
|
tap.test('should start parsing the CLI input', async () => {
|
2018-05-03 10:10:39 +00:00
|
|
|
smartCliTestObject.startParse();
|
2022-08-03 15:00:36 +00:00
|
|
|
expect(smartCliTestObject.parseCompleted.promise).toBeInstanceOf(Promise);
|
2018-05-03 10:10:39 +00:00
|
|
|
});
|
2017-04-23 13:21:08 +00:00
|
|
|
|
2018-05-03 10:10:39 +00:00
|
|
|
tap.start();
|