smartcli/test/test.ts

44 lines
1.2 KiB
TypeScript
Raw Normal View History

import { tap, expect } from 'tapbundle';
import { Subject } from 'rxjs';
2016-06-10 00:27:04 +00:00
import smartcli = require('../ts/index');
2017-04-22 19:03:28 +00:00
let smartCliTestObject: smartcli.Smartcli;
2017-04-22 19:03:28 +00:00
tap.test('should create a new Smartcli', async () => {
smartCliTestObject = new smartcli.Smartcli();
expect(smartCliTestObject).to.be.instanceof(smartcli.Smartcli);
});
2017-04-22 19:03:28 +00:00
tap.test('should add an command', async () => {
expect(smartCliTestObject.addCommand('awesome')).to.be.instanceOf(Subject);
});
2017-04-22 19:03:28 +00:00
tap.test('should start parsing a standardTask', async () => {
expect(smartCliTestObject.standardTask()).to.be.instanceOf(Subject);
});
2017-04-22 19:03:28 +00:00
let hasExecuted: boolean = false;
2017-04-22 19:03:28 +00:00
tap.test('should accept a command', async () => {
smartCliTestObject.addTrigger('triggerme').subscribe(() => {
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 () => {
expect(hasExecuted).to.be.false;
});
2017-04-22 20:09:51 +00:00
2017-04-22 19:03:28 +00:00
tap.test('should execute when triggered', async () => {
smartCliTestObject.trigger('triggerme');
expect(hasExecuted).be.true;
});
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 () => {
smartCliTestObject.startParse();
expect(smartCliTestObject.parseStarted.promise).to.be.instanceOf(Promise);
});
2017-04-23 13:21:08 +00:00
tap.start();