@inquirer/testing 2.1.9 → 2.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/cjs/index.js +7 -2
- package/dist/cjs/types/index.d.ts +6 -1
- package/dist/esm/index.mjs +7 -2
- package/dist/esm/types/index.d.mts +6 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -31,6 +31,7 @@ describe('input prompt', () => {
|
|
|
31
31
|
|
|
32
32
|
events.type('ohn');
|
|
33
33
|
events.keypress('enter');
|
|
34
|
+
// or events.keypress({ name: 'enter' })
|
|
34
35
|
|
|
35
36
|
await expect(answer).resolves.toEqual('John');
|
|
36
37
|
expect(getScreen()).toMatchInlineSnapshot(`"? What is your name John"`);
|
|
@@ -51,7 +52,7 @@ The core utility of `@inquirer/testing` is the `render()` function. This `render
|
|
|
51
52
|
|
|
52
53
|
1. `answer` (`Promise`) This is the promise that'll be resolved once an answer is provided and valid.
|
|
53
54
|
2. `getScreen` (`({ raw: boolean }) => string`) This function returns the state of what is printed on the command line screen at any given time. You can use its return value to validate your prompt is properly rendered. By default this function will strip the ANSI codes (used for colors.)
|
|
54
|
-
3. `events` (`{ keypress: (name) => void, type: (string) => void }`) Is the utilities allowing you to interact with the prompt. Use it to trigger keypress events, or typing any input.
|
|
55
|
+
3. `events` (`{ keypress: (name | Key) => void, type: (string) => void }`) Is the utilities allowing you to interact with the prompt. Use it to trigger keypress events, or typing any input.
|
|
55
56
|
4. `getFullOutput` (`() => string`) Return a raw dump of everything that got sent on the output stream.
|
|
56
57
|
|
|
57
58
|
You can refer to [the `@inquirer/input` prompt test suite](https://github.com/SBoudrias/Inquirer.js/blob/master/packages/input/input.test.mts) as a practical example.
|
package/dist/cjs/index.js
CHANGED
|
@@ -73,8 +73,13 @@ function render(prompt, props, options) {
|
|
|
73
73
|
yield Promise.resolve();
|
|
74
74
|
yield Promise.resolve();
|
|
75
75
|
const events = {
|
|
76
|
-
keypress(
|
|
77
|
-
|
|
76
|
+
keypress(key) {
|
|
77
|
+
if (typeof key === 'string') {
|
|
78
|
+
input.emit('keypress', null, { name: key });
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
input.emit('keypress', null, key);
|
|
82
|
+
}
|
|
78
83
|
},
|
|
79
84
|
type(text) {
|
|
80
85
|
input.write(text);
|
|
@@ -4,7 +4,12 @@ export declare function render<TestedPrompt extends Prompt<any, any>>(prompt: Te
|
|
|
4
4
|
answer: import("@inquirer/type").CancelablePromise<any>;
|
|
5
5
|
input: MuteStream;
|
|
6
6
|
events: {
|
|
7
|
-
keypress(
|
|
7
|
+
keypress(key: string | {
|
|
8
|
+
name?: string | undefined;
|
|
9
|
+
ctrl?: boolean | undefined;
|
|
10
|
+
meta?: boolean | undefined;
|
|
11
|
+
shift?: boolean | undefined;
|
|
12
|
+
}): void;
|
|
8
13
|
type(text: string): void;
|
|
9
14
|
};
|
|
10
15
|
getScreen({ raw }?: {
|
package/dist/esm/index.mjs
CHANGED
|
@@ -41,8 +41,13 @@ export async function render(prompt, props, options) {
|
|
|
41
41
|
await Promise.resolve();
|
|
42
42
|
await Promise.resolve();
|
|
43
43
|
const events = {
|
|
44
|
-
keypress(
|
|
45
|
-
|
|
44
|
+
keypress(key) {
|
|
45
|
+
if (typeof key === 'string') {
|
|
46
|
+
input.emit('keypress', null, { name: key });
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
input.emit('keypress', null, key);
|
|
50
|
+
}
|
|
46
51
|
},
|
|
47
52
|
type(text) {
|
|
48
53
|
input.write(text);
|
|
@@ -4,7 +4,12 @@ export declare function render<TestedPrompt extends Prompt<any, any>>(prompt: Te
|
|
|
4
4
|
answer: import("@inquirer/type").CancelablePromise<any>;
|
|
5
5
|
input: MuteStream;
|
|
6
6
|
events: {
|
|
7
|
-
keypress(
|
|
7
|
+
keypress(key: string | {
|
|
8
|
+
name?: string | undefined;
|
|
9
|
+
ctrl?: boolean | undefined;
|
|
10
|
+
meta?: boolean | undefined;
|
|
11
|
+
shift?: boolean | undefined;
|
|
12
|
+
}): void;
|
|
8
13
|
type(text: string): void;
|
|
9
14
|
};
|
|
10
15
|
getScreen({ raw }?: {
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/testing",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"engines": {
|
|
5
|
-
"node": ">=
|
|
5
|
+
"node": ">=18"
|
|
6
6
|
},
|
|
7
7
|
"description": "Inquirer testing utilities",
|
|
8
8
|
"main": "./dist/cjs/index.js",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"license": "MIT",
|
|
61
61
|
"homepage": "https://github.com/SBoudrias/Inquirer.js/blob/master/packages/testing/README.md",
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@inquirer/type": "^1.
|
|
63
|
+
"@inquirer/type": "^1.2.0",
|
|
64
64
|
"@types/mute-stream": "^0.0.4",
|
|
65
|
-
"@types/node": "^20.
|
|
65
|
+
"@types/node": "^20.11.16",
|
|
66
66
|
"ansi-escapes": "^4.3.2",
|
|
67
67
|
"mute-stream": "^1.0.0",
|
|
68
68
|
"strip-ansi": "^6.0.1"
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "44016a40bc9e93455dfdb9fa6c25c27c1c109bd3"
|
|
88
88
|
}
|