update tests

This commit is contained in:
Philipp Kunz 2017-04-22 22:09:51 +02:00
parent 3ff4c3ff2f
commit 5e66d35125
6 changed files with 28 additions and 30 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules/ node_modules/
coverage/ coverage/
public/ public/
.yarn/

View File

@ -1,3 +1,4 @@
import * as smartq from 'smartq';
import { Subject } from 'rxjs'; import { Subject } from 'rxjs';
import { Objectmap } from 'lik'; import { Objectmap } from 'lik';
export interface ICommandPromiseObject { export interface ICommandPromiseObject {
@ -11,7 +12,7 @@ export interface ITriggerObservableObject {
export declare class Smartcli { export declare class Smartcli {
argv: any; argv: any;
questionsDone: any; questionsDone: any;
parseStarted: any; parseStarted: smartq.Deferred<any>;
commands: any; commands: any;
questions: any; questions: any;
version: string; version: string;

View File

@ -35,7 +35,7 @@
"rxjs": "^5.3.0", "rxjs": "^5.3.0",
"smartparam": "0.1.1", "smartparam": "0.1.1",
"smartq": "^1.1.1", "smartq": "^1.1.1",
"typings-global": "^1.0.14", "typings-global": "^1.0.16",
"yargs": "^7.1.0" "yargs": "^7.1.0"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,4 +1,5 @@
import { tap, expect } from 'tapbundle' import { tap, expect } from 'tapbundle'
import { Subject } from 'rxjs'
import smartcli = require('../dist/index') import smartcli = require('../dist/index')
@ -7,20 +8,16 @@ let smartCliTestObject: smartcli.Smartcli
tap.test('should create a new Smartcli', async () => { tap.test('should create a new Smartcli', async () => {
smartCliTestObject = new smartcli.Smartcli() smartCliTestObject = new smartcli.Smartcli()
return expect(smartCliTestObject).be.instanceof(smartcli.Smartcli) return expect(smartCliTestObject).be.instanceof(smartcli.Smartcli)
}) }).catch(tap.threw)
tap.test('should add an command', async () => { tap.test('should add an command', async () => {
smartCliTestObject.addCommand('awesome') return expect(smartCliTestObject.addCommand('awesome')).to.not.throw
}) }).catch(tap.threw)
tap.test('should start parsing a standardTask', async () => { tap.test('should start parsing a standardTask', async () => {
smartCliTestObject.standardTask() return expect(smartCliTestObject.standardTask()).to.be.instanceOf(Promise)
.then(() => { }).catch(tap.threw)
console.log('this is the standard Task!')
})
})
let hasExecuted: boolean = false let hasExecuted: boolean = false
tap.test('should accept a command', async () => { tap.test('should accept a command', async () => {
@ -28,17 +25,20 @@ tap.test('should accept a command', async () => {
.subscribe(() => { .subscribe(() => {
hasExecuted = true hasExecuted = true
}) })
})
return expect(smartCliTestObject.addTrigger('triggerme')).to.be.instanceof(Subject)
}).catch(tap.threw)
tap.test('should not have executed yet', async () => { tap.test('should not have executed yet', async () => {
expect(hasExecuted).to.be.false return expect(hasExecuted).to.be.false
}) }).catch(tap.threw)
tap.test('should execute when triggered', async () => { tap.test('should execute when triggered', async () => {
smartCliTestObject.trigger('triggerme') smartCliTestObject.trigger('triggerme')
expect(hasExecuted).be.true return expect(hasExecuted).be.true
}) }).catch(tap.threw)
tap.test('should start parsing the CLI input', async () => { tap.test('should start parsing the CLI input', async () => {
smartCliTestObject.startParse() smartCliTestObject.startParse()
}) return await expect(smartCliTestObject.parseStarted.promise).to.eventually.be.fulfilled
}).catch(tap.threw)

View File

@ -20,7 +20,7 @@ export interface ITriggerObservableObject {
export class Smartcli { export class Smartcli {
argv: any argv: any
questionsDone questionsDone
parseStarted parseStarted: smartq.Deferred<any>
commands commands
questions questions
version: string version: string

View File

@ -1598,7 +1598,7 @@ set-blocking@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
shelljs@^0.7.4: shelljs@^0.7.7:
version "0.7.7" version "0.7.7"
resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.7.7.tgz#b2f5c77ef97148f4b4f6e22682e10bba8667cff1"
dependencies: dependencies:
@ -1899,12 +1899,12 @@ typed-promisify@^0.3.0:
version "0.3.0" version "0.3.0"
resolved "https://registry.yarnpkg.com/typed-promisify/-/typed-promisify-0.3.0.tgz#1ba0af5e444c87d8047406f18ce49092a1191853" resolved "https://registry.yarnpkg.com/typed-promisify/-/typed-promisify-0.3.0.tgz#1ba0af5e444c87d8047406f18ce49092a1191853"
typings-global@^1.0.14, typings-global@^1.0.3: typings-global@^1.0.14, typings-global@^1.0.16, typings-global@^1.0.3:
version "1.0.14" version "1.0.16"
resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.14.tgz#ab682720a03d6b9278869fb5c30c30d7dc61d12c" resolved "https://registry.yarnpkg.com/typings-global/-/typings-global-1.0.16.tgz#489b71781af24268750c2899316400a5e482961f"
dependencies: dependencies:
semver "^5.3.0" semver "^5.3.0"
shelljs "^0.7.4" shelljs "^0.7.7"
uglify-js@^2.6: uglify-js@^2.6:
version "2.8.22" version "2.8.22"
@ -1961,14 +1961,10 @@ window-size@0.1.0:
version "0.1.0" version "0.1.0"
resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d" resolved "https://registry.yarnpkg.com/window-size/-/window-size-0.1.0.tgz#5438cd2ea93b202efa3a19fe8887aee7c94f9c9d"
wordwrap@0.0.2: wordwrap@0.0.2, wordwrap@~0.0.2:
version "0.0.2" version "0.0.2"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f" resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.2.tgz#b79669bb42ecb409f83d583cad52ca17eaa1643f"
wordwrap@~0.0.2:
version "0.0.3"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107"
wrap-ansi@^2.0.0: wrap-ansi@^2.0.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"