change to an all rxjs Subject architecture
This commit is contained in:
52
test/test.ts
52
test/test.ts
@ -1,45 +1,43 @@
|
||||
import { tap, expect } from 'tapbundle'
|
||||
import { Subject } from 'rxjs'
|
||||
import { tap, expect } from 'tapbundle';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
import smartcli = require('../ts/index')
|
||||
import smartcli = require('../ts/index');
|
||||
|
||||
let smartCliTestObject: smartcli.Smartcli
|
||||
let smartCliTestObject: smartcli.Smartcli;
|
||||
|
||||
tap.test('should create a new Smartcli', async () => {
|
||||
smartCliTestObject = new smartcli.Smartcli()
|
||||
expect(smartCliTestObject).to.be.instanceof(smartcli.Smartcli)
|
||||
})
|
||||
smartCliTestObject = new smartcli.Smartcli();
|
||||
expect(smartCliTestObject).to.be.instanceof(smartcli.Smartcli);
|
||||
});
|
||||
|
||||
tap.test('should add an command', async () => {
|
||||
expect(smartCliTestObject.addCommand('awesome')).to.be.instanceOf(Promise)
|
||||
})
|
||||
expect(smartCliTestObject.addCommand('awesome')).to.be.instanceOf(Subject);
|
||||
});
|
||||
|
||||
tap.test('should start parsing a standardTask', async () => {
|
||||
expect(smartCliTestObject.standardTask()).to.be.instanceOf(Promise)
|
||||
})
|
||||
expect(smartCliTestObject.standardTask()).to.be.instanceOf(Subject);
|
||||
});
|
||||
|
||||
let hasExecuted: boolean = false
|
||||
let hasExecuted: boolean = false;
|
||||
|
||||
tap.test('should accept a command', async () => {
|
||||
smartCliTestObject.addTrigger('triggerme')
|
||||
.subscribe(() => {
|
||||
hasExecuted = true
|
||||
})
|
||||
expect(smartCliTestObject.addTrigger('triggerme')).to.be.instanceof(Subject)
|
||||
})
|
||||
smartCliTestObject.addTrigger('triggerme').subscribe(() => {
|
||||
hasExecuted = true;
|
||||
});
|
||||
});
|
||||
|
||||
tap.test('should not have executed yet', async () => {
|
||||
expect(hasExecuted).to.be.false()
|
||||
})
|
||||
expect(hasExecuted).to.be.false;
|
||||
});
|
||||
|
||||
tap.test('should execute when triggered', async () => {
|
||||
smartCliTestObject.trigger('triggerme')
|
||||
expect(hasExecuted).be.true()
|
||||
})
|
||||
smartCliTestObject.trigger('triggerme');
|
||||
expect(hasExecuted).be.true;
|
||||
});
|
||||
|
||||
tap.test('should start parsing the CLI input', async () => {
|
||||
smartCliTestObject.startParse()
|
||||
expect(smartCliTestObject.parseStarted.promise).to.be.instanceOf(Promise)
|
||||
})
|
||||
smartCliTestObject.startParse();
|
||||
expect(smartCliTestObject.parseStarted.promise).to.be.instanceOf(Promise);
|
||||
});
|
||||
|
||||
tap.start()
|
||||
tap.start();
|
||||
|
Reference in New Issue
Block a user