node-pluginsmanager-plugin 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/test/2_plugin.js CHANGED
@@ -1,231 +1,231 @@
1
- "use strict";
2
-
3
- // deps
4
-
5
- // natives
6
- const { join } = require("path");
7
- const assert = require("assert");
8
-
9
- // locals
10
- const readJSONFile = require(join(__dirname, "..", "lib", "readJSONFile.js"));
11
- const Plugin = require(join(__dirname, "..", "lib", "main.js"));
12
-
13
- // tests
14
-
15
- describe("Plugin", () => {
16
-
17
- let plugin = null;
18
-
19
- it("should test constructor", () => {
20
-
21
- plugin = new Plugin(__dirname);
22
-
23
- assert.strictEqual(typeof plugin, "object", "Generated plugin is not an object");
24
- assert.strictEqual(plugin instanceof Plugin, true, "Generated plugin is not a Plugin instance");
25
-
26
- assert.strictEqual(typeof plugin.directory, "string", "Generated plugin directory is not a string");
27
- assert.strictEqual(plugin.directory, __dirname, "Generated plugin directory is not as expected");
28
-
29
- assert.strictEqual(typeof plugin.engines, "object", "Generated plugin engines is not an object");
30
- assert.strictEqual(typeof plugin.engines.node, "string", "Generated plugin engines node is not a string");
31
- assert.strictEqual(plugin.engines.node, ">=6.0.0", "Generated plugin engines node is not as expected");
32
-
33
- assert.strictEqual(typeof plugin.license, "string", "Generated plugin license is not a string");
34
- assert.strictEqual(plugin.license, "MIT", "Generated plugin license is not as expected");
35
-
36
- assert.strictEqual(typeof plugin.main, "string", "Generated plugin main is not a string");
37
- assert.strictEqual(plugin.main, "lib/main.js", "Generated plugin main is not as expected");
38
-
39
- });
40
-
41
- it("should test event", () => {
42
-
43
- return new Promise((resolve, reject) => {
44
-
45
- plugin
46
- .once("error", reject)
47
- .once("test", resolve)
48
- .emit("test");
49
-
50
- }).then(() => {
51
- return plugin.unload();
52
- });
53
-
54
- });
55
-
56
- it("should load data from inexistant directory", (done) => {
57
-
58
- plugin.directory = join(__dirname, "zsgfzeojrfnoaziendfzoe");
59
- plugin.loadDataFromPackageFile().then(() => {
60
- done(new Error("Inexistant directory used"));
61
- }).catch((err) => {
62
-
63
- assert.strictEqual(typeof err, "object", "Generated error is not an object");
64
- assert.strictEqual(err instanceof Error, true, "Generated error is not an Error instance");
65
-
66
- done();
67
-
68
- });
69
-
70
- });
71
-
72
- it("should load data from inexistant package file", (done) => {
73
-
74
- plugin.directory = join(__dirname);
75
- plugin.loadDataFromPackageFile().then(() => {
76
- done(new Error("Inexistant file loaded"));
77
- }).catch((err) => {
78
-
79
- assert.strictEqual(typeof err, "object", "Generated error is not an object");
80
- assert.strictEqual(err instanceof Error, true, "Generated error is not an Error instance");
81
-
82
- done();
83
-
84
- });
85
-
86
- });
87
-
88
- it("should load data from package file", () => {
89
-
90
- const DIRECTORY = join(__dirname, "..");
91
-
92
- plugin.directory = DIRECTORY;
93
-
94
- return plugin.loadDataFromPackageFile().then(() => {
95
-
96
- return readJSONFile(join(plugin.directory, "package.json"));
97
-
98
- }).then((data) => {
99
-
100
- // params
101
- return Promise.resolve().then(() => {
102
-
103
- assert.strictEqual(typeof plugin.directory, "string", "directory is not as expected");
104
- assert.deepStrictEqual(plugin.directory, DIRECTORY, "directory is not as expected");
105
-
106
- return Promise.resolve();
107
-
108
- // native
109
- }).then(() => {
110
-
111
- assert.strictEqual(typeof plugin.authors, "object", "authors is not as expected");
112
- assert.strictEqual(plugin.authors instanceof Array, true, "authors is not as expected");
113
- assert.deepStrictEqual(plugin.authors, [ data.author ], "authors is not as expected");
114
-
115
- return Promise.resolve();
116
-
117
- }).then(() => {
118
-
119
- assert.strictEqual(typeof plugin.description, "string", "description is not as expected");
120
- assert.deepStrictEqual(plugin.description, data.description, "description is not as expected");
121
-
122
- return Promise.resolve();
123
-
124
- }).then(() => {
125
-
126
- assert.strictEqual(typeof plugin.dependencies, "object", "dependencies is not as expected");
127
- assert.deepStrictEqual(plugin.dependencies, data.dependencies, "dependencies is not as expected");
128
-
129
- return Promise.resolve();
130
-
131
- }).then(() => {
132
-
133
- assert.strictEqual(typeof plugin.devDependencies, "object", "devDependencies is not as expected");
134
- assert.deepStrictEqual(plugin.devDependencies, data.devDependencies, "devDependencies is not as expected");
135
-
136
- return Promise.resolve();
137
-
138
- }).then(() => {
139
-
140
- assert.strictEqual(typeof plugin.engines, "object", "engines is not as expected");
141
- assert.deepStrictEqual(plugin.engines, data.engines, "engines is not as expected");
142
-
143
- return Promise.resolve();
144
-
145
- }).then(() => {
146
-
147
- assert.strictEqual(typeof plugin.license, "string", "license is not as expected");
148
- assert.deepStrictEqual(plugin.license, data.license, "license is not as expected");
149
-
150
- return Promise.resolve();
151
-
152
- }).then(() => {
153
-
154
- assert.strictEqual(typeof plugin.main, "string", "main is not as expected");
155
- assert.deepStrictEqual(plugin.main, data.main, "main is not as expected");
156
-
157
- return Promise.resolve();
158
-
159
- }).then(() => {
160
-
161
- assert.strictEqual(typeof plugin.name, "string", "name is not as expected");
162
- assert.deepStrictEqual(plugin.name, data.name, "name is not as expected");
163
-
164
- return Promise.resolve();
165
-
166
- }).then(() => {
167
-
168
- assert.strictEqual(typeof plugin.scripts, "object", "scripts is not as expected");
169
- assert.deepStrictEqual(plugin.scripts, data.scripts, "scripts is not as expected");
170
-
171
- return Promise.resolve();
172
-
173
- }).then(() => {
174
-
175
- assert.strictEqual(typeof plugin.version, "string", "version is not as expected");
176
- assert.deepStrictEqual(plugin.version, data.version, "version is not as expected");
177
-
178
- return Promise.resolve();
179
-
180
- // specifics
181
- }).then(() => {
182
-
183
- assert.strictEqual(typeof plugin.designs, "object", "designs is not as expected");
184
- assert.strictEqual(plugin.designs instanceof Array, true, "designs is not as expected");
185
- assert.deepStrictEqual(plugin.designs, [ join(DIRECTORY, "styles", "test.css") ], "designs is not as expected");
186
-
187
- return Promise.resolve();
188
-
189
- }).then(() => {
190
-
191
- assert.strictEqual(typeof plugin.javascripts, "object", "javascripts is not as expected");
192
- assert.strictEqual(plugin.javascripts instanceof Array, true, "javascripts is not as expected");
193
- assert.deepStrictEqual(plugin.javascripts, [ join(DIRECTORY, "scripts", "test.js") ], "javascripts is not as expected");
194
-
195
- return Promise.resolve();
196
-
197
- }).then(() => {
198
-
199
- assert.strictEqual(typeof plugin.templates, "object", "templates is not as expected");
200
- assert.strictEqual(plugin.templates instanceof Array, true, "templates is not as expected");
201
- assert.deepStrictEqual(plugin.templates, [ join(DIRECTORY, "templates", "test.html") ], "templates is not as expected");
202
-
203
- return Promise.resolve();
204
-
205
- });
206
-
207
- });
208
-
209
- });
210
-
211
- it("should load plugin", () => {
212
- return plugin.load("test load");
213
- });
214
-
215
- it("should unload plugin", () => {
216
- return plugin.unload("test unload");
217
- });
218
-
219
- it("should install plugin", () => {
220
- return plugin.install("test install");
221
- });
222
-
223
- it("should update plugin", () => {
224
- return plugin.update("test update");
225
- });
226
-
227
- it("should uninstall plugin", () => {
228
- return plugin.uninstall("test uninstall");
229
- });
230
-
231
- });
1
+ "use strict";
2
+
3
+ // deps
4
+
5
+ // natives
6
+ const { join } = require("path");
7
+ const assert = require("assert");
8
+
9
+ // locals
10
+ const readJSONFile = require(join(__dirname, "..", "lib", "readJSONFile.js"));
11
+ const Plugin = require(join(__dirname, "..", "lib", "main.js"));
12
+
13
+ // tests
14
+
15
+ describe("Plugin", () => {
16
+
17
+ let plugin = null;
18
+
19
+ it("should test constructor", () => {
20
+
21
+ plugin = new Plugin(__dirname);
22
+
23
+ assert.strictEqual(typeof plugin, "object", "Generated plugin is not an object");
24
+ assert.strictEqual(plugin instanceof Plugin, true, "Generated plugin is not a Plugin instance");
25
+
26
+ assert.strictEqual(typeof plugin.directory, "string", "Generated plugin directory is not a string");
27
+ assert.strictEqual(plugin.directory, __dirname, "Generated plugin directory is not as expected");
28
+
29
+ assert.strictEqual(typeof plugin.engines, "object", "Generated plugin engines is not an object");
30
+ assert.strictEqual(typeof plugin.engines.node, "string", "Generated plugin engines node is not a string");
31
+ assert.strictEqual(plugin.engines.node, ">=6.0.0", "Generated plugin engines node is not as expected");
32
+
33
+ assert.strictEqual(typeof plugin.license, "string", "Generated plugin license is not a string");
34
+ assert.strictEqual(plugin.license, "MIT", "Generated plugin license is not as expected");
35
+
36
+ assert.strictEqual(typeof plugin.main, "string", "Generated plugin main is not a string");
37
+ assert.strictEqual(plugin.main, "lib/main.js", "Generated plugin main is not as expected");
38
+
39
+ });
40
+
41
+ it("should test event", () => {
42
+
43
+ return new Promise((resolve, reject) => {
44
+
45
+ plugin
46
+ .once("error", reject)
47
+ .once("test", resolve)
48
+ .emit("test");
49
+
50
+ }).then(() => {
51
+ return plugin.unload();
52
+ });
53
+
54
+ });
55
+
56
+ it("should load data from inexistant directory", (done) => {
57
+
58
+ plugin.directory = join(__dirname, "zsgfzeojrfnoaziendfzoe");
59
+ plugin.loadDataFromPackageFile().then(() => {
60
+ done(new Error("Inexistant directory used"));
61
+ }).catch((err) => {
62
+
63
+ assert.strictEqual(typeof err, "object", "Generated error is not an object");
64
+ assert.strictEqual(err instanceof Error, true, "Generated error is not an Error instance");
65
+
66
+ done();
67
+
68
+ });
69
+
70
+ });
71
+
72
+ it("should load data from inexistant package file", (done) => {
73
+
74
+ plugin.directory = join(__dirname);
75
+ plugin.loadDataFromPackageFile().then(() => {
76
+ done(new Error("Inexistant file loaded"));
77
+ }).catch((err) => {
78
+
79
+ assert.strictEqual(typeof err, "object", "Generated error is not an object");
80
+ assert.strictEqual(err instanceof Error, true, "Generated error is not an Error instance");
81
+
82
+ done();
83
+
84
+ });
85
+
86
+ });
87
+
88
+ it("should load data from package file", () => {
89
+
90
+ const DIRECTORY = join(__dirname, "..");
91
+
92
+ plugin.directory = DIRECTORY;
93
+
94
+ return plugin.loadDataFromPackageFile().then(() => {
95
+
96
+ return readJSONFile(join(plugin.directory, "package.json"));
97
+
98
+ }).then((data) => {
99
+
100
+ // params
101
+ return Promise.resolve().then(() => {
102
+
103
+ assert.strictEqual(typeof plugin.directory, "string", "directory is not as expected");
104
+ assert.deepStrictEqual(plugin.directory, DIRECTORY, "directory is not as expected");
105
+
106
+ return Promise.resolve();
107
+
108
+ // native
109
+ }).then(() => {
110
+
111
+ assert.strictEqual(typeof plugin.authors, "object", "authors is not as expected");
112
+ assert.strictEqual(plugin.authors instanceof Array, true, "authors is not as expected");
113
+ assert.deepStrictEqual(plugin.authors, [ data.author ], "authors is not as expected");
114
+
115
+ return Promise.resolve();
116
+
117
+ }).then(() => {
118
+
119
+ assert.strictEqual(typeof plugin.description, "string", "description is not as expected");
120
+ assert.deepStrictEqual(plugin.description, data.description, "description is not as expected");
121
+
122
+ return Promise.resolve();
123
+
124
+ }).then(() => {
125
+
126
+ assert.strictEqual(typeof plugin.dependencies, "object", "dependencies is not as expected");
127
+ assert.deepStrictEqual(plugin.dependencies, data.dependencies, "dependencies is not as expected");
128
+
129
+ return Promise.resolve();
130
+
131
+ }).then(() => {
132
+
133
+ assert.strictEqual(typeof plugin.devDependencies, "object", "devDependencies is not as expected");
134
+ assert.deepStrictEqual(plugin.devDependencies, data.devDependencies, "devDependencies is not as expected");
135
+
136
+ return Promise.resolve();
137
+
138
+ }).then(() => {
139
+
140
+ assert.strictEqual(typeof plugin.engines, "object", "engines is not as expected");
141
+ assert.deepStrictEqual(plugin.engines, data.engines, "engines is not as expected");
142
+
143
+ return Promise.resolve();
144
+
145
+ }).then(() => {
146
+
147
+ assert.strictEqual(typeof plugin.license, "string", "license is not as expected");
148
+ assert.deepStrictEqual(plugin.license, data.license, "license is not as expected");
149
+
150
+ return Promise.resolve();
151
+
152
+ }).then(() => {
153
+
154
+ assert.strictEqual(typeof plugin.main, "string", "main is not as expected");
155
+ assert.deepStrictEqual(plugin.main, data.main, "main is not as expected");
156
+
157
+ return Promise.resolve();
158
+
159
+ }).then(() => {
160
+
161
+ assert.strictEqual(typeof plugin.name, "string", "name is not as expected");
162
+ assert.deepStrictEqual(plugin.name, data.name, "name is not as expected");
163
+
164
+ return Promise.resolve();
165
+
166
+ }).then(() => {
167
+
168
+ assert.strictEqual(typeof plugin.scripts, "object", "scripts is not as expected");
169
+ assert.deepStrictEqual(plugin.scripts, data.scripts, "scripts is not as expected");
170
+
171
+ return Promise.resolve();
172
+
173
+ }).then(() => {
174
+
175
+ assert.strictEqual(typeof plugin.version, "string", "version is not as expected");
176
+ assert.deepStrictEqual(plugin.version, data.version, "version is not as expected");
177
+
178
+ return Promise.resolve();
179
+
180
+ // specifics
181
+ }).then(() => {
182
+
183
+ assert.strictEqual(typeof plugin.designs, "object", "designs is not as expected");
184
+ assert.strictEqual(plugin.designs instanceof Array, true, "designs is not as expected");
185
+ assert.deepStrictEqual(plugin.designs, [ join(DIRECTORY, "styles", "test.css") ], "designs is not as expected");
186
+
187
+ return Promise.resolve();
188
+
189
+ }).then(() => {
190
+
191
+ assert.strictEqual(typeof plugin.javascripts, "object", "javascripts is not as expected");
192
+ assert.strictEqual(plugin.javascripts instanceof Array, true, "javascripts is not as expected");
193
+ assert.deepStrictEqual(plugin.javascripts, [ join(DIRECTORY, "scripts", "test.js") ], "javascripts is not as expected");
194
+
195
+ return Promise.resolve();
196
+
197
+ }).then(() => {
198
+
199
+ assert.strictEqual(typeof plugin.templates, "object", "templates is not as expected");
200
+ assert.strictEqual(plugin.templates instanceof Array, true, "templates is not as expected");
201
+ assert.deepStrictEqual(plugin.templates, [ join(DIRECTORY, "templates", "test.html") ], "templates is not as expected");
202
+
203
+ return Promise.resolve();
204
+
205
+ });
206
+
207
+ });
208
+
209
+ });
210
+
211
+ it("should load plugin", () => {
212
+ return plugin.load("test load");
213
+ });
214
+
215
+ it("should unload plugin", () => {
216
+ return plugin.unload("test unload");
217
+ });
218
+
219
+ it("should install plugin", () => {
220
+ return plugin.install("test install");
221
+ });
222
+
223
+ it("should update plugin", () => {
224
+ return plugin.update("test update");
225
+ });
226
+
227
+ it("should uninstall plugin", () => {
228
+ return plugin.uninstall("test uninstall");
229
+ });
230
+
231
+ });
@@ -1,15 +1,15 @@
1
- /// <reference path="../../lib/index.d.ts" />
2
-
3
- import Plugin = require("../../lib/main.js");
4
-
5
- console.log(Plugin);
6
-
7
- const plugin = new Plugin();
8
-
9
- console.log(plugin);
10
-
11
- console.log(plugin.directory);
12
-
13
- plugin.load().then(() => {
14
- return plugin.unload();
15
- });
1
+ /// <reference path="../../lib/index.d.ts" />
2
+
3
+ import Plugin from "../../lib/main.js";
4
+
5
+ console.log(Plugin);
6
+
7
+ const plugin = new Plugin();
8
+
9
+ console.log(plugin);
10
+
11
+ console.log(plugin.directory);
12
+
13
+ plugin.load().then(() => {
14
+ return plugin.unload();
15
+ });