diff --git a/package.json b/package.json index e1e12869..adbe9555 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@oclif/tslint": "^1.1.2", "@types/ansi-styles": "^3.2.0", "@types/chai": "^4.1.3", + "@types/chai-as-promised": "^7.1.0", "@types/clean-stack": "^1.3.0", "@types/extract-stack": "^1.0.0", "@types/fs-extra": "^5.0.2", @@ -39,6 +40,7 @@ "@types/strip-ansi": "^3.0.0", "@types/supports-color": "^5.3.0", "chai": "^4.1.2", + "chai-as-promised": "^7.1.1", "concurrently": "^3.5.1", "eslint": "^4.19.1", "eslint-config-oclif": "^1.5.1", diff --git a/test/prompt.test.ts b/test/prompt.test.ts index 7603540d..06ec2d05 100644 --- a/test/prompt.test.ts +++ b/test/prompt.test.ts @@ -1,6 +1,12 @@ +import * as chai from 'chai' +import chaiAsPromised from 'chai-as-promised' + +chai.use(chaiAsPromised) +const expect = chai.expect + import cli from '../src' -import {expect, fancy} from './fancy' +import {fancy} from './fancy' describe('prompt', () => { fancy @@ -32,7 +38,7 @@ describe('prompt', () => { .stdout() .stderr() .end('timeouts with no input', async () => { - const response = await cli.prompt('Require input?', {timeout: 100}) - expect(response).to.not.exist + await expect(cli.prompt('Require input?', {timeout: 1})) + .to.eventually.be.rejectedWith('timed out') }) }) diff --git a/yarn.lock b/yarn.lock index 7e783c21..87f80a4c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -32,7 +32,13 @@ dependencies: "@types/color-name" "*" -"@types/chai@^4.1.3": +"@types/chai-as-promised@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@types/chai-as-promised/-/chai-as-promised-7.1.0.tgz#010b04cde78eacfb6e72bfddb3e58fe23c2e78b9" + dependencies: + "@types/chai" "*" + +"@types/chai@*", "@types/chai@^4.1.3": version "4.1.3" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.1.3.tgz#b8a74352977a23b604c01aa784f5b793443fb7dc" @@ -225,6 +231,12 @@ cardinal@^2.1.1: ansicolors "~0.3.2" redeyed "~2.1.0" +chai-as-promised@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/chai-as-promised/-/chai-as-promised-7.1.1.tgz#08645d825deb8696ee61725dbf590c012eb00ca0" + dependencies: + check-error "^1.0.2" + chai@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/chai/-/chai-4.1.2.tgz#0f64584ba642f0f2ace2806279f4f06ca23ad73c" @@ -276,7 +288,7 @@ chardet@^0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" -check-error@^1.0.1: +check-error@^1.0.1, check-error@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"