@inquirer/testing 3.3.2 → 3.3.3
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/dist/jest.js +17 -15
- package/dist/vitest.js +30 -35
- package/package.json +6 -6
package/dist/jest.js
CHANGED
|
@@ -172,22 +172,24 @@ jest.mock('@inquirer/external-editor', () => {
|
|
|
172
172
|
return {};
|
|
173
173
|
}
|
|
174
174
|
return {
|
|
175
|
-
editAsync: (_text
|
|
175
|
+
editAsync: (_text) => {
|
|
176
176
|
let buffer = '';
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
177
|
+
return new Promise((resolve) => {
|
|
178
|
+
const typeSpy = jest
|
|
179
|
+
.spyOn(screenInstance, 'type')
|
|
180
|
+
.mockImplementation((text) => {
|
|
181
|
+
buffer += text;
|
|
182
|
+
});
|
|
183
|
+
const keypressSpy = jest
|
|
184
|
+
.spyOn(screenInstance, 'keypress')
|
|
185
|
+
.mockImplementation((key) => {
|
|
186
|
+
const name = typeof key === 'string' ? key : key.name;
|
|
187
|
+
if (name === 'enter' || name === 'return') {
|
|
188
|
+
typeSpy.mockRestore();
|
|
189
|
+
keypressSpy.mockRestore();
|
|
190
|
+
resolve(buffer);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
191
193
|
});
|
|
192
194
|
},
|
|
193
195
|
};
|
package/dist/vitest.js
CHANGED
|
@@ -37,19 +37,6 @@ export function wrapPrompt(prompt) {
|
|
|
37
37
|
return promise;
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
|
-
// Prompt names used by the @inquirer/prompts barrel mock to wrap only prompt exports.
|
|
41
|
-
const promptNames = [
|
|
42
|
-
'input',
|
|
43
|
-
'select',
|
|
44
|
-
'confirm',
|
|
45
|
-
'checkbox',
|
|
46
|
-
'password',
|
|
47
|
-
'expand',
|
|
48
|
-
'rawlist',
|
|
49
|
-
'number',
|
|
50
|
-
'search',
|
|
51
|
-
'editor',
|
|
52
|
-
];
|
|
53
40
|
// Mock individual prompt packages (covers `import input from '@inquirer/input'` style).
|
|
54
41
|
// All prompt packages are optional peer dependencies, so factories silently skip
|
|
55
42
|
// packages that aren't installed in the consumer's project.
|
|
@@ -150,13 +137,19 @@ vi.mock('@inquirer/editor', async (importOriginal) => {
|
|
|
150
137
|
vi.mock('@inquirer/prompts', async (importOriginal) => {
|
|
151
138
|
try {
|
|
152
139
|
const actual = await importOriginal();
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
140
|
+
return {
|
|
141
|
+
...actual,
|
|
142
|
+
input: wrapPrompt(actual.input),
|
|
143
|
+
select: wrapPrompt(actual.select),
|
|
144
|
+
confirm: wrapPrompt(actual.confirm),
|
|
145
|
+
checkbox: wrapPrompt(actual.checkbox),
|
|
146
|
+
password: wrapPrompt(actual.password),
|
|
147
|
+
expand: wrapPrompt(actual.expand),
|
|
148
|
+
rawlist: wrapPrompt(actual.rawlist),
|
|
149
|
+
number: wrapPrompt(actual.number),
|
|
150
|
+
search: wrapPrompt(actual.search),
|
|
151
|
+
editor: wrapPrompt(actual.editor),
|
|
152
|
+
};
|
|
160
153
|
}
|
|
161
154
|
catch {
|
|
162
155
|
return {};
|
|
@@ -173,22 +166,24 @@ vi.mock('@inquirer/external-editor', async (importOriginal) => {
|
|
|
173
166
|
return {};
|
|
174
167
|
}
|
|
175
168
|
return {
|
|
176
|
-
editAsync: (_text
|
|
169
|
+
editAsync: (_text) => {
|
|
177
170
|
let buffer = '';
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
171
|
+
return new Promise((resolve) => {
|
|
172
|
+
const typeSpy = vi
|
|
173
|
+
.spyOn(screenInstance, 'type')
|
|
174
|
+
.mockImplementation((text) => {
|
|
175
|
+
buffer += text;
|
|
176
|
+
});
|
|
177
|
+
const keypressSpy = vi
|
|
178
|
+
.spyOn(screenInstance, 'keypress')
|
|
179
|
+
.mockImplementation((key) => {
|
|
180
|
+
const name = typeof key === 'string' ? key : key.name;
|
|
181
|
+
if (name === 'enter' || name === 'return') {
|
|
182
|
+
typeSpy.mockRestore();
|
|
183
|
+
keypressSpy.mockRestore();
|
|
184
|
+
resolve(buffer);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
192
187
|
});
|
|
193
188
|
},
|
|
194
189
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inquirer/testing",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.3",
|
|
4
4
|
"description": "Inquirer testing utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"answer",
|
|
@@ -83,16 +83,16 @@
|
|
|
83
83
|
"tsc": "tsc"
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@inquirer/type": "^4.0.
|
|
86
|
+
"@inquirer/type": "^4.0.5",
|
|
87
87
|
"@xterm/headless": "^6.0.0",
|
|
88
88
|
"mute-stream": "^3.0.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@types/jest": "^30.0.0",
|
|
92
92
|
"@types/mute-stream": "^0.0.4",
|
|
93
|
-
"@types/node": "^25.
|
|
94
|
-
"typescript": "^
|
|
95
|
-
"vitest": "^4.
|
|
93
|
+
"@types/node": "^25.5.2",
|
|
94
|
+
"typescript": "^6.0.2",
|
|
95
|
+
"vitest": "^4.1.2"
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
98
|
"@inquirer/checkbox": ">=1.0.0",
|
|
@@ -167,5 +167,5 @@
|
|
|
167
167
|
},
|
|
168
168
|
"main": "./dist/index.js",
|
|
169
169
|
"types": "./dist/index.d.ts",
|
|
170
|
-
"gitHead": "
|
|
170
|
+
"gitHead": "e68fe01d65359e083581c48c4a18cd8f97d88842"
|
|
171
171
|
}
|