-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathplugin-prepare.ts
66 lines (57 loc) · 2.03 KB
/
plugin-prepare.ts
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
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);
}
protected getPreviouslyPreparedDependencies(platform: string): IDictionary<boolean> {
return this.previouslyPrepared;
}
protected beforePrepare(dependencies: IDictionary<IDependencyData>, platform: string): void {
_.values(dependencies).forEach(d => {
this.preparedDependencies[d.name] = true;
});
}
protected afterPrepare(dependencies: IDictionary<IDependencyData>, platform: string): void {
// DO NOTHING
}
}
describe("Plugin preparation", () => {
it("skips prepare if no plugins", () => {
const pluginPrepare = new TestNpmPluginPrepare({});
pluginPrepare.preparePlugins({}, "android");
assert.deepEqual({}, pluginPrepare.preparedDependencies);
});
it("skips prepare if every plugin prepared", () => {
const pluginPrepare = new TestNpmPluginPrepare({"tns-core-modules-widgets": true});
const testDependencies: IDictionary<IDependencyData> = {
"0": {
name: "tns-core-modules-widgets",
version: "1.0.0",
nativescript: null,
}
};
pluginPrepare.preparePlugins(testDependencies, "android");
assert.deepEqual({}, pluginPrepare.preparedDependencies);
});
it("saves prepared plugins after preparation", () => {
const pluginPrepare = new TestNpmPluginPrepare({"tns-core-modules-widgets": true});
const testDependencies: IDictionary<IDependencyData> = {
"0": {
name: "tns-core-modules-widgets",
version: "1.0.0",
nativescript: null,
},
"1": {
name: "nativescript-calendar",
version: "1.0.0",
nativescript: null,
}
};
pluginPrepare.preparePlugins(testDependencies, "android");
const prepareData = {"tns-core-modules-widgets": true, "nativescript-calendar": true};
assert.deepEqual(prepareData, pluginPrepare.preparedDependencies);
});
});