-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added promptModule test helper
- Loading branch information
1 parent
27e4ed5
commit 1ed108f
Showing
5 changed files
with
290 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
'use strict' | ||
const { suite, test } = require('mocha') | ||
const assert = require('assert') | ||
const utils = require('../utils') | ||
|
||
suite('utils', () => { | ||
suite('promptModule', async () => { | ||
test('take options and run assertions and return output', async () => { | ||
const prompts = [{ | ||
name: 'example', | ||
message: 'example:', | ||
type: 'input', | ||
when: true | ||
}, { | ||
name: 'example2', | ||
message: 'example two:', | ||
type: 'input', | ||
when: false | ||
}] | ||
|
||
const pm = utils.test.promptModule({ | ||
assertCount: 1, | ||
prompts: { | ||
example: 'test input', | ||
example2: { | ||
value: 'example2 test input', | ||
assert: (p) => { | ||
assert.deepStrictEqual(p, prompts[1]) | ||
} | ||
} | ||
} | ||
})() | ||
|
||
const output = await pm(prompts) | ||
|
||
assert.deepStrictEqual(output, { | ||
example: 'test input' | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.