Skip to content

Commit d490f11

Browse files
committed
test: add file test for editor
1 parent 6a4ce5d commit d490f11

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

packages/core/test/prompts/editor.test.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { vol } from 'memfs';
1+
import { fs, vol } from 'memfs';
22
import { cursor } from 'sisteransi';
33
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
44
import { default as EditorPrompt } from '../../src/prompts/editor.js';
@@ -93,6 +93,33 @@ describe('EditorPrompt', () => {
9393
});
9494
});
9595

96+
describe("file", () => {
97+
test("created on start", () => {
98+
const instance = new EditorPrompt({
99+
input,
100+
output,
101+
render: () => 'foo',
102+
});
103+
104+
instance.prompt();
105+
106+
expect(fs.existsSync(instance.path)).to.equal(true);
107+
})
108+
109+
test("removed on end", () => {
110+
const instance = new EditorPrompt({
111+
input,
112+
output,
113+
render: () => 'foo',
114+
});
115+
116+
instance.prompt();
117+
input.emit('keypress', '\r', { name: 'return' });
118+
119+
expect(fs.existsSync(instance.path)).to.equal(false);
120+
})
121+
})
122+
96123
describe('executable', () => {
97124
const originalEnv = structuredClone(process.env);
98125
const originalPlatform = process.platform;

0 commit comments

Comments
 (0)