-
-
Notifications
You must be signed in to change notification settings - Fork 201
Expand file tree
/
Copy pathplugin-prepare.ts
More file actions
55 lines (47 loc) · 1.68 KB
/
plugin-prepare.ts
File metadata and controls
55 lines (47 loc) · 1.68 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
import { assert } from "chai";
import { NpmPluginPrepare } from "../lib/tools/node-modules/node-modules-dest-copy";
require("should");
class TestNpmPluginPrepare extends NpmPluginPrepare {
public preparedDependencies: IDictionary<boolean> = {};
constructor(private previouslyPrepared: IDictionary<boolean>) {
super(null, null, null, null);
}
protected getPreviouslyPreparedDependencies(platform: string): IDictionary<boolean> {
return this.previouslyPrepared;
}
protected async beforePrepare(dependencies: IDependencyData[], platform: string): Promise<void> {
_.each(dependencies, d => {
this.preparedDependencies[d.name] = true;
});
}
protected async afterPrepare(dependencies: IDependencyData[], platform: string): Promise<void> {
// DO NOTHING
}
}
describe("Plugin preparation", () => {
it("skips prepare if no plugins", async () => {
const pluginPrepare = new TestNpmPluginPrepare({});
await pluginPrepare.preparePlugins([], "android", null, {});
assert.deepEqual({}, pluginPrepare.preparedDependencies);
});
it("saves prepared plugins after preparation", async () => {
const pluginPrepare = new TestNpmPluginPrepare({ "tns-core-modules-widgets": true });
const testDependencies: IDependencyData[] = [
{
name: "tns-core-modules-widgets",
depth: 0,
directory: "some dir",
nativescript: null,
},
{
name: "nativescript-calendar",
depth: 0,
directory: "some dir",
nativescript: null,
}
];
await pluginPrepare.preparePlugins(testDependencies, "android", null, {});
const prepareData = { "tns-core-modules-widgets": true, "nativescript-calendar": true };
assert.deepEqual(prepareData, pluginPrepare.preparedDependencies);
});
});