-
-
Notifications
You must be signed in to change notification settings - Fork 417
Expand file tree
/
Copy pathpluginService.test.ts
More file actions
101 lines (89 loc) · 2.78 KB
/
Copy pathpluginService.test.ts
File metadata and controls
101 lines (89 loc) · 2.78 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { expect } from "chai";
import * as fs from "fs-extra";
import * as os from "os";
import * as path from "path";
import {
IInstalledExtensionInformation,
InstalledExtensionsService
} from "../../../src/service/installedExtensions.service";
describe("PluginService", () => {
describe("MergeInstalledExtensionsFromDisk", () => {
let extensionFolder: string;
beforeEach(() => {
extensionFolder = fs.mkdtempSync(
path.join(os.tmpdir(), "settings-sync-extensions-")
);
});
afterEach(() => {
fs.removeSync(extensionFolder);
});
it("should include installed extensions that are not returned by the VS Code API", () => {
const enabledExtension: IInstalledExtensionInformation = {
metadata: {
date: undefined,
downloadUrl: undefined,
galleryApiUrl: undefined,
id: "enabled-id",
publisherDisplayName: "Sample",
publisherId: "sample"
},
name: "enabled",
publisher: "sample",
version: "1.0.0"
};
fs.mkdirpSync(path.join(extensionFolder, "sample.disabled-2.0.0"));
fs.writeJSONSync(
path.join(extensionFolder, "sample.disabled-2.0.0", "package.json"),
{
__metadata: {
id: "disabled-id",
publisherDisplayName: "Sample",
publisherId: "sample"
},
name: "disabled",
publisher: "sample",
version: "2.0.0"
}
);
const extensions = InstalledExtensionsService.MergeFromExtensionFolder(
[enabledExtension],
extensionFolder
);
expect(extensions.map(ext => `${ext.publisher}.${ext.name}`)).to.deep.eq([
"sample.enabled",
"sample.disabled"
]);
expect(extensions[1].version).to.eq("2.0.0");
});
it("should not duplicate extensions that are already returned by the VS Code API", () => {
const extension: IInstalledExtensionInformation = {
metadata: {
date: undefined,
downloadUrl: undefined,
galleryApiUrl: undefined,
id: "enabled-id",
publisherDisplayName: "Sample",
publisherId: "sample"
},
name: "enabled",
publisher: "sample",
version: "1.0.0"
};
fs.mkdirpSync(path.join(extensionFolder, "sample.enabled-1.0.0"));
fs.writeJSONSync(
path.join(extensionFolder, "sample.enabled-1.0.0", "package.json"),
{
name: "enabled",
publisher: "sample",
version: "1.0.0"
}
);
const extensions = InstalledExtensionsService.MergeFromExtensionFolder(
[extension],
extensionFolder
);
expect(extensions).to.have.length(1);
expect(extensions[0].name).to.eq("enabled");
});
});
});