Skip to content

Commit 748bfaa

Browse files
committed
try to fix vscode tests on windows
1 parent 847763b commit 748bfaa

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

renamify-vscode/extension/src/test/suite/cliService.test.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as assert from 'node:assert/strict';
22
import { spawn } from 'node:child_process';
33
import { EventEmitter } from 'node:events';
4+
import * as fs from 'node:fs';
5+
import * as os from 'node:os';
46
import * as path from 'node:path';
57
import * as sinon from 'sinon';
68
import * as vscode from 'vscode';
@@ -133,16 +135,34 @@ suite('CLI Service Test Suite', () => {
133135
test('CLI service performs a real search', async function () {
134136
this.timeout(5000); // Increase timeout to 5 seconds
135137

136-
const service = new RenamifyCliService();
138+
// Create a temporary test directory with a small file to search
139+
const testDir = path.join(os.tmpdir(), `renamify-test-${Date.now()}`);
140+
fs.mkdirSync(testDir, { recursive: true });
137141

138-
// Test basic search with default case styles
139-
const results = await service.search('test', {
140-
caseStyles: ['original'],
141-
});
142+
// Create a test file with searchable content
143+
const testFile = path.join(testDir, 'test.txt');
144+
fs.writeFileSync(testFile, 'This is a test file with test content');
145+
146+
// Change to test directory to limit search scope
147+
const originalCwd = process.cwd();
148+
process.chdir(testDir);
149+
150+
try {
151+
const service = new RenamifyCliService();
142152

143-
// Results should be a Plan object
144-
assert.ok(results.id, 'Plan should have an ID');
145-
assert.ok(Array.isArray(results.matches), 'Matches should be an array');
153+
// Test basic search with default case styles
154+
const results = await service.search('test', {
155+
caseStyles: ['original'],
156+
});
157+
158+
// Results should be a Plan object
159+
assert.ok(results.id, 'Plan should have an ID');
160+
assert.ok(Array.isArray(results.matches), 'Matches should be an array');
161+
} finally {
162+
// Restore original directory and clean up
163+
process.chdir(originalCwd);
164+
fs.rmSync(testDir, { recursive: true, force: true });
165+
}
146166
});
147167

148168
test('CLI service uses --only-styles argument correctly', async () => {

0 commit comments

Comments
 (0)