-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathworkspace-recommendations.test.ts
More file actions
77 lines (67 loc) · 2.56 KB
/
workspace-recommendations.test.ts
File metadata and controls
77 lines (67 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Workspace recommendations tests.
* Verifies workspace recommendation functionality for Dev Proxy Toolkit.
*/
import * as assert from 'assert';
import * as vscode from 'vscode';
import * as path from 'path';
import {
hasDevProxyConfig,
isExtensionRecommended,
addExtensionToRecommendations,
sleep,
} from '../utils';
import { Extension } from '../constants';
import { getExtensionContext, testDevProxyInstall } from './helpers';
suite('Workspace Recommendations', () => {
let tempWorkspaceFolder: vscode.WorkspaceFolder;
let tempDir: string;
setup(async () => {
const context = await getExtensionContext();
await context.globalState.update('devProxyInstall', testDevProxyInstall);
// Create a temporary directory for test files
tempDir = path.join(process.cwd(), '.test-workspace-' + Date.now());
try {
await vscode.workspace.fs.createDirectory(vscode.Uri.file(tempDir));
} catch {
// Directory might already exist
}
tempWorkspaceFolder = {
uri: vscode.Uri.file(tempDir),
name: 'test-workspace',
index: 0,
};
});
teardown(async () => {
// Clean up test files
try {
await vscode.workspace.fs.delete(vscode.Uri.file(tempDir), { recursive: true });
} catch {
// Ignore errors
}
});
test('hasDevProxyConfig should return false when no config files exist', async () => {
const result = await hasDevProxyConfig();
// In the actual workspace, we don't expect config files unless they're in test/examples
// This is a best-effort test
assert.ok(result !== undefined);
});
test('isExtensionRecommended should return false when extensions.json does not exist', async () => {
// This test requires a workspace folder, but we can't easily mock it
// Just ensure the function runs without error
const result = await isExtensionRecommended();
assert.ok(result === false || result === true);
});
test('addExtensionToRecommendations should create extensions.json if it does not exist', async () => {
// This test requires manipulating workspace folders, which is difficult in tests
// We'll just ensure the function is callable
const result = await addExtensionToRecommendations();
assert.ok(result === false || result === true);
});
test('Extension constant should have correct ID', () => {
assert.strictEqual(Extension.id, 'garrytrinder.dev-proxy-toolkit');
});
test('Extension constant should have correct extensions.json path', () => {
assert.strictEqual(Extension.extensionsJsonPath, '.vscode/extensions.json');
});
});