not-node 6.2.18 → 6.2.19
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/.husky/pre-commit +4 -0
- package/package.json +7 -4
- package/src/auth/roles.js +9 -1
- package/src/auth/rules.js +5 -5
- package/src/cli/actions/env.mjs +1 -1
- package/src/cli/actions/nginx.mjs +1 -1
- package/src/cli/actions/pm2.mjs +1 -1
- package/src/common.js +1 -1
- package/src/domain.js +36 -24
- package/src/identity/providers/session.js +3 -0
- package/src/manifest/batchRunner.js +5 -1
- package/src/manifest/registrator/fields.js +4 -4
- package/src/manifest/route.js +1 -0
- package/src/model/exceptions.js +3 -3
- package/src/model/versioning.js +2 -2
- package/test/auth/routes.js +34 -10
- package/test/fakes.js +52 -0
- package/test/identity/providers/session.js +14 -5
- package/test/identity/providers/token.js +1 -1
- package/test/init/additional.js +31 -33
- package/test/init/app.js +66 -10
- package/test/init/bodyparser.js +4 -1
- package/test/init/compression.js +4 -1
- package/test/init/cors.js +5 -1
- package/test/init/csp.js +2 -2
- package/test/init/db.js +5 -1
- package/test/init/env.js +12 -2
- package/test/init/express.js +4 -1
- package/test/init/fileupload.js +4 -1
- package/test/init/http.js +21 -4
- package/test/init/middleware.js +13 -1
- package/test/init/routes.js +1 -0
- package/test/init/sessions/mongoose.js +5 -1
- package/test/init/sessions/redis.js +5 -1
- package/test/init/sessions.js +21 -15
- package/test/init/static.js +4 -1
- package/test/init/template.js +5 -1
- package/test/model/versioning.js +3 -3
- package/test/module/fields.js +45 -20
- package/test/module/index.js +26 -15
- package/test/notApp.js +221 -187
- package/test/notDomain.js +799 -707
- package/test/notManifestFilter.js +385 -322
- package/test/notModule.js +689 -644
- package/test/notRoute.js +112 -99
- package/test/testies/module/fields/collection.js +16 -14
- package/test/testies/module/fields/single.js +11 -11
package/test/notDomain.js
CHANGED
|
@@ -1,777 +1,869 @@
|
|
|
1
|
-
const expect = require(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const path = require(
|
|
6
|
-
const pathToModules = path.join(__dirname,
|
|
7
|
-
|
|
8
|
-
describe(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
});
|
|
1
|
+
const expect = require("chai").expect,
|
|
2
|
+
notModule = require("../src/manifest/module"),
|
|
3
|
+
notDomain = require("../src/domain");
|
|
4
|
+
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const pathToModules = path.join(__dirname, "./testies/modules");
|
|
7
|
+
|
|
8
|
+
describe("notDomain", function () {
|
|
9
|
+
describe("forEachMod", function () {
|
|
10
|
+
it("modules not empty", function () {
|
|
11
|
+
const ctx = {
|
|
12
|
+
modules: {
|
|
13
|
+
user: {
|
|
14
|
+
module: true,
|
|
15
|
+
},
|
|
16
|
+
jom: false,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
notDomain.prototype.forEachMod.call(ctx, (modName, mod) => {
|
|
20
|
+
expect(modName).to.be.equal("user");
|
|
21
|
+
expect(mod).to.be.deep.equal({
|
|
22
|
+
module: true,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
});
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
describe('importModulesFrom', function() {
|
|
36
|
-
it('modules not empty', function() {
|
|
37
|
-
let modsList = [];
|
|
38
|
-
const ctx = {
|
|
39
|
-
importModuleFrom(path, file){
|
|
40
|
-
modsList.push(file);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
notDomain.prototype.importModulesFrom.call(ctx, pathToModules);
|
|
44
|
-
expect(modsList).to.be.deep.equal([
|
|
45
|
-
'not-test-module',
|
|
46
|
-
'post',
|
|
47
|
-
'user'
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('importModuleFrom', function() {
|
|
53
|
-
it('module not empty', function() {
|
|
54
|
-
let imported = false;
|
|
55
|
-
const pathToModule = path.join(pathToModules, 'user');
|
|
56
|
-
const ctx = {
|
|
57
|
-
options:{
|
|
58
|
-
mongoose: require('mongoose')
|
|
59
|
-
},
|
|
60
|
-
importModule(mod, name){
|
|
61
|
-
expect(mod).to.be.instanceof(notModule);
|
|
62
|
-
expect(name).to.be.equal('testModule');
|
|
63
|
-
imported = true;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
notDomain.prototype.importModuleFrom.call(ctx, pathToModule, 'testModule');
|
|
67
|
-
expect(imported).to.be.true;
|
|
27
|
+
it("modules empty", function () {
|
|
28
|
+
const ctx = {};
|
|
29
|
+
notDomain.prototype.forEachMod.call(ctx, () => {});
|
|
30
|
+
});
|
|
68
31
|
});
|
|
69
32
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('importModule', function() {
|
|
89
|
-
it('module not empty', function() {
|
|
90
|
-
const mod = {
|
|
91
|
-
mod: true
|
|
92
|
-
};
|
|
93
|
-
const ctx = {
|
|
94
|
-
modules:{}
|
|
95
|
-
};
|
|
96
|
-
notDomain.prototype.importModule.call(ctx, mod, 'testModule');
|
|
97
|
-
expect(ctx.modules.testModule).to.be.ok;
|
|
98
|
-
expect(ctx.modules.testModule).to.be.deep.equal(mod);
|
|
33
|
+
describe("importModulesFrom", function () {
|
|
34
|
+
it("modules not empty", function () {
|
|
35
|
+
let modsList = [];
|
|
36
|
+
const ctx = {
|
|
37
|
+
importModuleFrom(path, file) {
|
|
38
|
+
modsList.push(file);
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
notDomain.prototype.importModulesFrom.call(ctx, pathToModules);
|
|
42
|
+
expect(modsList).to.be.deep.equal([
|
|
43
|
+
"not-test-module",
|
|
44
|
+
"post",
|
|
45
|
+
"user",
|
|
46
|
+
]);
|
|
47
|
+
});
|
|
99
48
|
});
|
|
100
|
-
});
|
|
101
49
|
|
|
50
|
+
describe("importModuleFrom", function () {
|
|
51
|
+
it("module not empty", function () {
|
|
52
|
+
let imported = false;
|
|
53
|
+
const pathToModule = path.join(pathToModules, "user");
|
|
54
|
+
const ctx = {
|
|
55
|
+
options: {
|
|
56
|
+
mongoose: require("mongoose"),
|
|
57
|
+
},
|
|
58
|
+
importModule(mod, name) {
|
|
59
|
+
expect(mod).to.be.instanceof(notModule);
|
|
60
|
+
expect(name).to.be.equal("not-user");
|
|
61
|
+
imported = true;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
notDomain.prototype.importModuleFrom.call(
|
|
65
|
+
ctx,
|
|
66
|
+
pathToModule,
|
|
67
|
+
"testModule"
|
|
68
|
+
);
|
|
69
|
+
expect(imported).to.be.true;
|
|
70
|
+
});
|
|
102
71
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
72
|
+
it("module not empty, moduleName empty", function () {
|
|
73
|
+
let imported = false;
|
|
74
|
+
const pathToModule = path.join(pathToModules, "user");
|
|
75
|
+
const ctx = {
|
|
76
|
+
options: {
|
|
77
|
+
mongoose: require("mongoose"),
|
|
78
|
+
},
|
|
79
|
+
importModule(mod, name) {
|
|
80
|
+
expect(mod).to.be.instanceof(notModule);
|
|
81
|
+
expect(name).to.be.equal("not-user");
|
|
82
|
+
imported = true;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
notDomain.prototype.importModuleFrom.call(ctx, pathToModule);
|
|
86
|
+
expect(imported).to.be.true;
|
|
87
|
+
});
|
|
111
88
|
});
|
|
112
89
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
90
|
+
describe("importModule", function () {
|
|
91
|
+
it("module not empty", function () {
|
|
92
|
+
const mod = {
|
|
93
|
+
mod: true,
|
|
94
|
+
};
|
|
95
|
+
const fModules = {};
|
|
96
|
+
const ctx = {
|
|
97
|
+
modules: fModules,
|
|
98
|
+
getModule(name) {
|
|
99
|
+
return fModules[name];
|
|
100
|
+
},
|
|
101
|
+
setModule(name, val) {
|
|
102
|
+
fModules[name] = val;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
notDomain.prototype.importModule.call(ctx, mod, "testModule");
|
|
106
|
+
expect(ctx.modules.testModule).to.be.ok;
|
|
107
|
+
expect(ctx.modules.testModule).to.be.deep.equal(mod);
|
|
108
|
+
});
|
|
130
109
|
});
|
|
131
110
|
|
|
111
|
+
describe("getRoute", function () {
|
|
112
|
+
it("route name missformed", function () {
|
|
113
|
+
const route = "myWay";
|
|
114
|
+
const ctx = {};
|
|
115
|
+
const res = notDomain.prototype.getRoute.call(ctx, route);
|
|
116
|
+
expect(res).to.be.null;
|
|
117
|
+
});
|
|
132
118
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
getRoute(){
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
const res = notDomain.prototype.getRoute.call(ctx, route);
|
|
164
|
-
expect(res).to.be.null;
|
|
165
|
-
});
|
|
119
|
+
it("route name ok, module, route and action exists", function () {
|
|
120
|
+
const route = "not-user//user//myWay";
|
|
121
|
+
const id = Math.random();
|
|
122
|
+
const fModules = {
|
|
123
|
+
"not-user": {
|
|
124
|
+
getRoute() {
|
|
125
|
+
return {
|
|
126
|
+
myWay() {
|
|
127
|
+
return id;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
const ctx = {
|
|
134
|
+
modules: fModules,
|
|
135
|
+
getModule(name) {
|
|
136
|
+
return fModules[name];
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
const res = notDomain.prototype.getRoute.call(ctx, route);
|
|
140
|
+
expect(typeof res).to.be.equal("function");
|
|
141
|
+
expect(res()).to.be.equal(id);
|
|
142
|
+
});
|
|
166
143
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
expect(res).to.be.null;
|
|
191
|
-
});
|
|
144
|
+
it("route name ok, module not exists", function () {
|
|
145
|
+
const route = "not-user//user//myWay";
|
|
146
|
+
const id = Math.random();
|
|
147
|
+
const fModules = {
|
|
148
|
+
"not-user1": {
|
|
149
|
+
getRoute() {
|
|
150
|
+
return {
|
|
151
|
+
myWay() {
|
|
152
|
+
return id;
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
const ctx = {
|
|
159
|
+
modules: fModules,
|
|
160
|
+
getModule(name) {
|
|
161
|
+
return fModules[name];
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
const res = notDomain.prototype.getRoute.call(ctx, route);
|
|
165
|
+
expect(res).to.be.null;
|
|
166
|
+
});
|
|
192
167
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
expect(res).to.be.equal(id);
|
|
213
|
-
});
|
|
168
|
+
it("route name ok, module exists, route not exists", function () {
|
|
169
|
+
const route = "not-user//user//myWay";
|
|
170
|
+
const id = Math.random();
|
|
171
|
+
const fModules = {
|
|
172
|
+
"not-user": {
|
|
173
|
+
getRoute() {
|
|
174
|
+
return false;
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
const ctx = {
|
|
179
|
+
modules: fModules,
|
|
180
|
+
getModule(name) {
|
|
181
|
+
return fModules[name];
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
const res = notDomain.prototype.getRoute.call(ctx, route);
|
|
185
|
+
expect(res).to.be.null;
|
|
186
|
+
});
|
|
214
187
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
};
|
|
234
|
-
const res = notDomain.prototype.getModelSchema.call(ctx, route);
|
|
235
|
-
expect(res).to.be.equal(id);
|
|
188
|
+
it("route name ok, module exists, route exists, actio not exists", function () {
|
|
189
|
+
const route = "not-user//user//myWay";
|
|
190
|
+
const fModules = {
|
|
191
|
+
"not-user": {
|
|
192
|
+
getRoute() {
|
|
193
|
+
return {};
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
const ctx = {
|
|
198
|
+
modules: fModules,
|
|
199
|
+
getModule(name) {
|
|
200
|
+
return fModules[name];
|
|
201
|
+
},
|
|
202
|
+
};
|
|
203
|
+
const res = notDomain.prototype.getRoute.call(ctx, route);
|
|
204
|
+
expect(res).to.be.null;
|
|
205
|
+
});
|
|
236
206
|
});
|
|
237
207
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
describe('getLogic', function() {
|
|
251
|
-
it('name short', function() {
|
|
252
|
-
const id = Math.random();
|
|
253
|
-
const route = 'Jungle';
|
|
254
|
-
const ctx = {
|
|
255
|
-
getByPath(){return id;}
|
|
256
|
-
};
|
|
257
|
-
const res = notDomain.prototype.getLogic.call(ctx, route);
|
|
258
|
-
expect(res).to.be.equal(id);
|
|
259
|
-
});
|
|
208
|
+
describe("getModel", function () {
|
|
209
|
+
it("model name short", function () {
|
|
210
|
+
const route = "Jungle";
|
|
211
|
+
const ctx = {
|
|
212
|
+
getByPath() {
|
|
213
|
+
return null;
|
|
214
|
+
},
|
|
215
|
+
};
|
|
216
|
+
const res = notDomain.prototype.getModel.call(ctx, route);
|
|
217
|
+
expect(res).to.be.null;
|
|
218
|
+
});
|
|
260
219
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
describe('getLogicFile', function() {
|
|
273
|
-
it('name short', function() {
|
|
274
|
-
const id = Math.random();
|
|
275
|
-
const route = 'Jungle';
|
|
276
|
-
const ctx = {
|
|
277
|
-
getByPath(){return id;}
|
|
278
|
-
};
|
|
279
|
-
const res = notDomain.prototype.getLogicFile.call(ctx, route);
|
|
280
|
-
expect(res).to.be.equal(id);
|
|
220
|
+
it("model name full", function () {
|
|
221
|
+
const id = Math.random();
|
|
222
|
+
const route = "module//Jungle";
|
|
223
|
+
const ctx = {
|
|
224
|
+
getByPath() {
|
|
225
|
+
return id;
|
|
226
|
+
},
|
|
227
|
+
};
|
|
228
|
+
const res = notDomain.prototype.getModel.call(ctx, route);
|
|
229
|
+
expect(res).to.be.equal(id);
|
|
230
|
+
});
|
|
281
231
|
});
|
|
282
232
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
describe('getByFullPath', function() {
|
|
296
|
-
it('path exists', function() {
|
|
297
|
-
const id = Math.random();
|
|
298
|
-
const path = 'user//resource';
|
|
299
|
-
const type = 'File';
|
|
300
|
-
const ctx = {
|
|
301
|
-
modules:{
|
|
302
|
-
user:{
|
|
303
|
-
getFile(name){
|
|
304
|
-
expect(name).to.be.equal('resource');
|
|
305
|
-
return id;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
const res = notDomain.prototype.getByFullPath.call(ctx, path, type);
|
|
311
|
-
expect(res).to.be.equal(id);
|
|
312
|
-
});
|
|
233
|
+
describe("getModelFile", function () {
|
|
234
|
+
it("name short", function () {
|
|
235
|
+
const id = Math.random();
|
|
236
|
+
const route = "Jungle";
|
|
237
|
+
const ctx = {
|
|
238
|
+
getByPath() {
|
|
239
|
+
return id;
|
|
240
|
+
},
|
|
241
|
+
};
|
|
242
|
+
const res = notDomain.prototype.getModelFile.call(ctx, route);
|
|
243
|
+
expect(res).to.be.equal(id);
|
|
244
|
+
});
|
|
313
245
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
326
|
-
};
|
|
327
|
-
const res = notDomain.prototype.getByFullPath.call(ctx, path, type);
|
|
328
|
-
expect(res).to.be.null;
|
|
246
|
+
it("name full", function () {
|
|
247
|
+
const id = Math.random();
|
|
248
|
+
const route = "module//Jungle";
|
|
249
|
+
const ctx = {
|
|
250
|
+
getByPath() {
|
|
251
|
+
return id;
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
const res = notDomain.prototype.getModelFile.call(ctx, route);
|
|
255
|
+
expect(res).to.be.equal(id);
|
|
256
|
+
});
|
|
329
257
|
});
|
|
330
258
|
|
|
331
|
-
|
|
259
|
+
describe("getModelSchema", function () {
|
|
260
|
+
it("name short", function () {
|
|
261
|
+
const id = Math.random();
|
|
262
|
+
const route = "Jungle";
|
|
263
|
+
const ctx = {
|
|
264
|
+
getByPath() {
|
|
265
|
+
return id;
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
const res = notDomain.prototype.getModelSchema.call(ctx, route);
|
|
269
|
+
expect(res).to.be.equal(id);
|
|
270
|
+
});
|
|
332
271
|
|
|
272
|
+
it("name full", function () {
|
|
273
|
+
const id = Math.random();
|
|
274
|
+
const route = "module//Jungle";
|
|
275
|
+
const ctx = {
|
|
276
|
+
getByPath() {
|
|
277
|
+
return id;
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
const res = notDomain.prototype.getModelSchema.call(ctx, route);
|
|
281
|
+
expect(res).to.be.equal(id);
|
|
282
|
+
});
|
|
283
|
+
});
|
|
333
284
|
|
|
285
|
+
describe("getLogic", function () {
|
|
286
|
+
it("name short", function () {
|
|
287
|
+
const id = Math.random();
|
|
288
|
+
const route = "Jungle";
|
|
289
|
+
const ctx = {
|
|
290
|
+
getByPath() {
|
|
291
|
+
return id;
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
const res = notDomain.prototype.getLogic.call(ctx, route);
|
|
295
|
+
expect(res).to.be.equal(id);
|
|
296
|
+
});
|
|
334
297
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
getFile(name){
|
|
347
|
-
expect(name).to.be.equal('resource');
|
|
348
|
-
return id;
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
const res = notDomain.prototype.getByShortPath.call(ctx, path, type);
|
|
354
|
-
expect(res).to.be.equal(id);
|
|
298
|
+
it("name full", function () {
|
|
299
|
+
const id = Math.random();
|
|
300
|
+
const route = "module//Jungle";
|
|
301
|
+
const ctx = {
|
|
302
|
+
getByPath() {
|
|
303
|
+
return id;
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
const res = notDomain.prototype.getLogic.call(ctx, route);
|
|
307
|
+
expect(res).to.be.equal(id);
|
|
308
|
+
});
|
|
355
309
|
});
|
|
356
310
|
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
const res = notDomain.prototype.getByShortPath.call(ctx, path, type);
|
|
370
|
-
expect(res).to.be.null;
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
describe('getModule', function() {
|
|
375
|
-
it('exists', function() {
|
|
376
|
-
const route = 'user';
|
|
377
|
-
const ctx = {
|
|
378
|
-
modules:{
|
|
379
|
-
user:{
|
|
380
|
-
mod: 'user'
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
};
|
|
384
|
-
const res = notDomain.prototype.getModule.call(ctx, route);
|
|
385
|
-
expect(res).to.be.deep.equal({
|
|
386
|
-
mod: 'user'
|
|
387
|
-
});
|
|
388
|
-
});
|
|
311
|
+
describe("getLogicFile", function () {
|
|
312
|
+
it("name short", function () {
|
|
313
|
+
const id = Math.random();
|
|
314
|
+
const route = "Jungle";
|
|
315
|
+
const ctx = {
|
|
316
|
+
getByPath() {
|
|
317
|
+
return id;
|
|
318
|
+
},
|
|
319
|
+
};
|
|
320
|
+
const res = notDomain.prototype.getLogicFile.call(ctx, route);
|
|
321
|
+
expect(res).to.be.equal(id);
|
|
322
|
+
});
|
|
389
323
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
};
|
|
403
|
-
const res = notDomain.prototype.getModule.call(ctx, route);
|
|
404
|
-
expect(res).to.be.deep.equal(targetMod);
|
|
324
|
+
it("name full", function () {
|
|
325
|
+
const id = Math.random();
|
|
326
|
+
const route = "module//Jungle";
|
|
327
|
+
const ctx = {
|
|
328
|
+
getByPath() {
|
|
329
|
+
return id;
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
const res = notDomain.prototype.getLogicFile.call(ctx, route);
|
|
333
|
+
expect(res).to.be.equal(id);
|
|
334
|
+
});
|
|
405
335
|
});
|
|
406
336
|
|
|
337
|
+
describe("getByFullPath", function () {
|
|
338
|
+
it("path exists", function () {
|
|
339
|
+
const id = Math.random();
|
|
340
|
+
const path = "user//resource";
|
|
341
|
+
const type = "File";
|
|
342
|
+
const fModules = {
|
|
343
|
+
user: {
|
|
344
|
+
getFile(name) {
|
|
345
|
+
expect(name).to.be.equal("resource");
|
|
346
|
+
return id;
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
};
|
|
350
|
+
const ctx = {
|
|
351
|
+
modules: fModules,
|
|
352
|
+
getModule(name) {
|
|
353
|
+
return fModules[name];
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
const res = notDomain.prototype.getByFullPath.call(ctx, path, type);
|
|
357
|
+
expect(res).to.be.equal(id);
|
|
358
|
+
});
|
|
407
359
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
it('exec - ok', async ()=> {
|
|
429
|
-
let executed = 0;
|
|
430
|
-
const method = 'jump';
|
|
431
|
-
const ctx = {
|
|
432
|
-
modules:{
|
|
433
|
-
user:{
|
|
434
|
-
exec(){
|
|
435
|
-
executed++;
|
|
436
|
-
}
|
|
437
|
-
},
|
|
438
|
-
dof:{
|
|
439
|
-
async exec(){
|
|
440
|
-
executed++;
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
},
|
|
444
|
-
report(e){
|
|
445
|
-
expect(e).to.be.instanceof(Error);
|
|
446
|
-
}
|
|
447
|
-
};
|
|
448
|
-
await notDomain.prototype.execInModules.call(ctx, method);
|
|
449
|
-
expect(executed).to.be.equal(2);
|
|
360
|
+
it("path not exists", function () {
|
|
361
|
+
const path = "usesr//resource";
|
|
362
|
+
const type = "File";
|
|
363
|
+
const fModules = {
|
|
364
|
+
user: {
|
|
365
|
+
getFile(name) {
|
|
366
|
+
expect(name).to.be.equal("resource");
|
|
367
|
+
return id;
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
const ctx = {
|
|
372
|
+
modules: fModules,
|
|
373
|
+
getModule(name) {
|
|
374
|
+
return fModules[name];
|
|
375
|
+
},
|
|
376
|
+
};
|
|
377
|
+
const res = notDomain.prototype.getByFullPath.call(ctx, path, type);
|
|
378
|
+
expect(res).to.be.null;
|
|
379
|
+
});
|
|
450
380
|
});
|
|
451
381
|
|
|
382
|
+
describe("getByShortPath", function () {
|
|
383
|
+
it("path exists", function () {
|
|
384
|
+
const id = Math.random();
|
|
385
|
+
const path = "resource";
|
|
386
|
+
const type = "File";
|
|
387
|
+
const fModules = {
|
|
388
|
+
lite: {
|
|
389
|
+
getFile() {
|
|
390
|
+
return false;
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
user: {
|
|
394
|
+
getFile(name) {
|
|
395
|
+
expect(name).to.be.equal("resource");
|
|
396
|
+
return id;
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
const ctx = {
|
|
401
|
+
modules: fModules,
|
|
402
|
+
getModule(name) {
|
|
403
|
+
return fModules[name];
|
|
404
|
+
},
|
|
405
|
+
};
|
|
406
|
+
const res = notDomain.prototype.getByShortPath.call(
|
|
407
|
+
ctx,
|
|
408
|
+
path,
|
|
409
|
+
type
|
|
410
|
+
);
|
|
411
|
+
expect(res).to.be.equal(id);
|
|
412
|
+
});
|
|
452
413
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
failed = true;
|
|
477
|
-
expect(e).to.be.equal('execution failed');
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
await notDomain.prototype.execInModules.call(ctx, method);
|
|
481
|
-
expect(executed).to.be.equal(2);
|
|
482
|
-
expect(failed).to.be.true;
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
describe('fabricate', function() {
|
|
488
|
-
it('modules', function() {
|
|
489
|
-
let cnt = 0;
|
|
490
|
-
const ctx = {
|
|
491
|
-
modules:{
|
|
492
|
-
user:{
|
|
493
|
-
fabricateModels(){cnt++;}
|
|
494
|
-
},
|
|
495
|
-
load:{
|
|
496
|
-
fabricateModels(){cnt++;}
|
|
497
|
-
},
|
|
498
|
-
loaf:{},
|
|
499
|
-
mepty:{
|
|
500
|
-
fabricateModels(){cnt++;}
|
|
501
|
-
},
|
|
502
|
-
}
|
|
503
|
-
};
|
|
504
|
-
notDomain.prototype.fabricate.call(ctx);
|
|
505
|
-
expect(cnt).to.be.equal(3);
|
|
414
|
+
it("path not exists", function () {
|
|
415
|
+
const path = "usesr";
|
|
416
|
+
const type = "File";
|
|
417
|
+
const fModules = {
|
|
418
|
+
user: {
|
|
419
|
+
getFile() {
|
|
420
|
+
return null;
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
const ctx = {
|
|
425
|
+
modules: fModules,
|
|
426
|
+
getModule(name) {
|
|
427
|
+
return fModules[name];
|
|
428
|
+
},
|
|
429
|
+
};
|
|
430
|
+
const res = notDomain.prototype.getByShortPath.call(
|
|
431
|
+
ctx,
|
|
432
|
+
path,
|
|
433
|
+
type
|
|
434
|
+
);
|
|
435
|
+
expect(res).to.be.null;
|
|
436
|
+
});
|
|
506
437
|
});
|
|
507
|
-
});
|
|
508
438
|
|
|
439
|
+
describe("getModule", function () {
|
|
440
|
+
it("exists", function () {
|
|
441
|
+
const route = "user";
|
|
442
|
+
const fModules = {
|
|
443
|
+
user: {
|
|
444
|
+
mod: "user",
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
const ctx = {
|
|
448
|
+
modules: fModules,
|
|
449
|
+
getModule(name) {
|
|
450
|
+
return fModules[name];
|
|
451
|
+
},
|
|
452
|
+
};
|
|
453
|
+
const res = notDomain.prototype.getModule.call(ctx, route);
|
|
454
|
+
expect(res).to.be.deep.equal({
|
|
455
|
+
mod: "user",
|
|
456
|
+
});
|
|
457
|
+
});
|
|
509
458
|
|
|
459
|
+
it("exists, but with custom name", function () {
|
|
460
|
+
const route = "Jungle";
|
|
461
|
+
const targetMod = {
|
|
462
|
+
getName() {
|
|
463
|
+
return "Jungle";
|
|
464
|
+
},
|
|
465
|
+
};
|
|
466
|
+
const fModules = {
|
|
467
|
+
loop: {
|
|
468
|
+
getName() {
|
|
469
|
+
return "loop";
|
|
470
|
+
},
|
|
471
|
+
},
|
|
472
|
+
trees: targetMod,
|
|
473
|
+
};
|
|
474
|
+
const ctx = {
|
|
475
|
+
modules: fModules,
|
|
476
|
+
getModule(name) {
|
|
477
|
+
return fModules[name];
|
|
478
|
+
},
|
|
479
|
+
};
|
|
480
|
+
const res = notDomain.prototype.getModule.call(ctx, route);
|
|
481
|
+
expect(res).to.be.deep.equal(targetMod);
|
|
482
|
+
});
|
|
510
483
|
|
|
484
|
+
it("not exists", function () {
|
|
485
|
+
const route = "Jungle";
|
|
486
|
+
const targetMod = {
|
|
487
|
+
getName() {
|
|
488
|
+
return "Jungle1";
|
|
489
|
+
},
|
|
490
|
+
};
|
|
491
|
+
const fModules = {
|
|
492
|
+
loop: {
|
|
493
|
+
getName() {
|
|
494
|
+
return "loop";
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
trees: targetMod,
|
|
498
|
+
};
|
|
499
|
+
const ctx = {
|
|
500
|
+
modules: fModules,
|
|
501
|
+
getModule(name) {
|
|
502
|
+
return fModules[name];
|
|
503
|
+
},
|
|
504
|
+
};
|
|
505
|
+
const res = notDomain.prototype.getModule.call(ctx, route);
|
|
506
|
+
expect(res).to.be.null;
|
|
507
|
+
});
|
|
508
|
+
});
|
|
511
509
|
|
|
510
|
+
//execInModules
|
|
511
|
+
describe("execInModules", function () {
|
|
512
|
+
it("exec - ok", async () => {
|
|
513
|
+
let executed = 0;
|
|
514
|
+
const method = "jump";
|
|
515
|
+
const fModules = {
|
|
516
|
+
user: {
|
|
517
|
+
exec() {
|
|
518
|
+
executed++;
|
|
519
|
+
},
|
|
520
|
+
},
|
|
521
|
+
dof: {
|
|
522
|
+
async exec() {
|
|
523
|
+
executed++;
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
};
|
|
527
|
+
const ctx = {
|
|
528
|
+
modules: fModules,
|
|
529
|
+
report(e) {
|
|
530
|
+
expect(e).to.be.instanceof(Error);
|
|
531
|
+
},
|
|
532
|
+
getModule(name) {
|
|
533
|
+
return fModules[name];
|
|
534
|
+
},
|
|
535
|
+
};
|
|
536
|
+
await notDomain.prototype.execInModules.call(ctx, method);
|
|
537
|
+
expect(executed).to.be.equal(2);
|
|
538
|
+
});
|
|
512
539
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
540
|
+
it("exec - one failed, other runned", async () => {
|
|
541
|
+
let executed = 0,
|
|
542
|
+
failed = false;
|
|
543
|
+
const method = "jump";
|
|
544
|
+
const fModules = {
|
|
545
|
+
user: {
|
|
546
|
+
exec() {
|
|
547
|
+
executed++;
|
|
548
|
+
},
|
|
549
|
+
},
|
|
550
|
+
dof: {
|
|
551
|
+
async exec() {
|
|
552
|
+
throw "execution failed";
|
|
553
|
+
},
|
|
554
|
+
},
|
|
555
|
+
loaf: {
|
|
556
|
+
async exec() {
|
|
557
|
+
expect(failed).to.be.true;
|
|
558
|
+
executed++;
|
|
559
|
+
},
|
|
560
|
+
},
|
|
561
|
+
};
|
|
562
|
+
const ctx = {
|
|
563
|
+
modules: fModules,
|
|
564
|
+
getModule(name) {
|
|
565
|
+
return fModules[name];
|
|
566
|
+
},
|
|
567
|
+
report(e) {
|
|
568
|
+
failed = true;
|
|
569
|
+
expect(e).to.be.equal("execution failed");
|
|
570
|
+
},
|
|
571
|
+
};
|
|
572
|
+
await notDomain.prototype.execInModules.call(ctx, method);
|
|
573
|
+
expect(executed).to.be.equal(2);
|
|
574
|
+
expect(failed).to.be.true;
|
|
575
|
+
});
|
|
519
576
|
});
|
|
520
577
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
578
|
+
describe("fabricate", function () {
|
|
579
|
+
it("modules", function () {
|
|
580
|
+
let cnt = 0;
|
|
581
|
+
const fModules = {
|
|
582
|
+
user: {
|
|
583
|
+
fabricateModels() {
|
|
584
|
+
cnt++;
|
|
585
|
+
},
|
|
586
|
+
},
|
|
587
|
+
load: {
|
|
588
|
+
fabricateModels() {
|
|
589
|
+
cnt++;
|
|
590
|
+
},
|
|
591
|
+
},
|
|
592
|
+
loaf: {},
|
|
593
|
+
mepty: {
|
|
594
|
+
fabricateModels() {
|
|
595
|
+
cnt++;
|
|
596
|
+
},
|
|
597
|
+
},
|
|
598
|
+
};
|
|
599
|
+
const ctx = {
|
|
600
|
+
modules: fModules,
|
|
601
|
+
getModule(name) {
|
|
602
|
+
return fModules[name];
|
|
603
|
+
},
|
|
604
|
+
};
|
|
605
|
+
notDomain.prototype.fabricate.call(ctx);
|
|
606
|
+
expect(cnt).to.be.equal(3);
|
|
607
|
+
});
|
|
532
608
|
});
|
|
533
|
-
});
|
|
534
609
|
|
|
610
|
+
describe("logger", function () {
|
|
611
|
+
it("getter/setter", function () {
|
|
612
|
+
const dom = new notDomain({});
|
|
613
|
+
expect(dom.logger).to.be.deep.equal(console);
|
|
614
|
+
dom.logger = "happy";
|
|
615
|
+
expect(dom.logger).to.be.deep.equal("happy");
|
|
616
|
+
});
|
|
535
617
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
618
|
+
it("log", function (done) {
|
|
619
|
+
const dom = new notDomain({});
|
|
620
|
+
const params = ["leet", 2, { cold: true }];
|
|
621
|
+
expect(dom.logger).to.be.deep.equal(console);
|
|
622
|
+
dom.logger = {
|
|
623
|
+
log() {
|
|
624
|
+
expect(Array.from(arguments)).to.be.deep.equal(params);
|
|
625
|
+
done();
|
|
626
|
+
},
|
|
627
|
+
};
|
|
628
|
+
dom.log(...params);
|
|
629
|
+
});
|
|
542
630
|
});
|
|
543
631
|
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
632
|
+
describe("reporter", function () {
|
|
633
|
+
it("getter/setter", function () {
|
|
634
|
+
const dom = new notDomain({});
|
|
635
|
+
expect(dom.reporter).to.have.keys(["report"]);
|
|
636
|
+
dom.reporter = "happy";
|
|
637
|
+
expect(dom.reporter).to.be.deep.equal("happy");
|
|
638
|
+
});
|
|
639
|
+
|
|
640
|
+
it("report", function () {
|
|
641
|
+
const dom = new notDomain({});
|
|
642
|
+
const params = ["leet", 2, { cold: true }];
|
|
643
|
+
dom.report("some data");
|
|
644
|
+
dom.reporter = {
|
|
645
|
+
async report(...somedata) {
|
|
646
|
+
expect(somedata).to.be.deep.equal(params);
|
|
647
|
+
throw "ok";
|
|
648
|
+
},
|
|
649
|
+
};
|
|
650
|
+
try {
|
|
651
|
+
dom.reporter.report(params);
|
|
652
|
+
} catch (e) {
|
|
653
|
+
expect(e).to.be.equal("ok");
|
|
654
|
+
}
|
|
655
|
+
});
|
|
559
656
|
});
|
|
560
|
-
});
|
|
561
657
|
|
|
658
|
+
describe("informer", function () {
|
|
659
|
+
it("getter/setter", function () {
|
|
660
|
+
const dom = new notDomain({});
|
|
661
|
+
expect(dom.informer).to.have.keys(["now"]);
|
|
662
|
+
dom.informer = "happy";
|
|
663
|
+
expect(dom.informer).to.be.deep.equal("happy");
|
|
664
|
+
});
|
|
562
665
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
666
|
+
it("inform", function () {
|
|
667
|
+
const dom = new notDomain({});
|
|
668
|
+
const params = ["leet", 2, { cold: true }];
|
|
669
|
+
dom.inform("some data");
|
|
670
|
+
dom.inform = {
|
|
671
|
+
async now(...somedata) {
|
|
672
|
+
expect(somedata).to.be.deep.equal(params);
|
|
673
|
+
throw "ok";
|
|
674
|
+
},
|
|
675
|
+
};
|
|
676
|
+
try {
|
|
677
|
+
dom.inform.now(params);
|
|
678
|
+
} catch (e) {
|
|
679
|
+
expect(e).to.be.equal("ok");
|
|
680
|
+
}
|
|
681
|
+
});
|
|
569
682
|
});
|
|
570
683
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
expect(somedata).to.be.deep.equal(params);
|
|
578
|
-
throw 'ok';
|
|
579
|
-
}
|
|
580
|
-
};
|
|
581
|
-
try{
|
|
582
|
-
dom.inform.now(params);
|
|
583
|
-
}catch(e){
|
|
584
|
-
expect(e).to.be.equal('ok');
|
|
585
|
-
}
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
describe('addWSServer', function() {
|
|
590
|
-
it('set', function() {
|
|
591
|
-
const ctx = {
|
|
592
|
-
_wss:{}
|
|
593
|
-
};
|
|
594
|
-
notDomain.prototype.addWSServer.call(ctx, 'key', 'happy');
|
|
595
|
-
expect(ctx._wss.key).to.be.deep.equal('happy');
|
|
684
|
+
describe("addWSServer", function () {
|
|
685
|
+
it("set", function () {
|
|
686
|
+
const dom = new notDomain({});
|
|
687
|
+
dom.addWSServer("key", "happy");
|
|
688
|
+
expect(dom.WSServer("key")).to.be.deep.equal("happy");
|
|
689
|
+
});
|
|
596
690
|
});
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
691
|
+
|
|
692
|
+
describe("WSServer", function () {
|
|
693
|
+
it("default(main) exists", function () {
|
|
694
|
+
const dom = new notDomain({});
|
|
695
|
+
dom.addWSServer("main", "happy");
|
|
696
|
+
const res = dom.WSServer();
|
|
697
|
+
expect(res).to.be.equal("happy");
|
|
698
|
+
});
|
|
699
|
+
|
|
700
|
+
it("default(main) not exists", function () {
|
|
701
|
+
const dom = new notDomain({});
|
|
702
|
+
const res = dom.WSServer();
|
|
703
|
+
expect(res).to.be.undefined;
|
|
704
|
+
});
|
|
609
705
|
});
|
|
610
706
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
expect(res).to.be.undefined;
|
|
707
|
+
describe("addWSClient", function () {
|
|
708
|
+
it("set", function () {
|
|
709
|
+
const dom = new notDomain({});
|
|
710
|
+
dom.addWSClient("key", "happy");
|
|
711
|
+
expect(dom.WSClient("key")).to.be.deep.equal("happy");
|
|
712
|
+
});
|
|
618
713
|
});
|
|
619
|
-
});
|
|
620
714
|
|
|
715
|
+
describe("WSClient", function () {
|
|
716
|
+
it("main exists", function () {
|
|
717
|
+
const dom = new notDomain({});
|
|
718
|
+
dom.addWSClient("main", "happy");
|
|
719
|
+
const res = dom.WSClient("main");
|
|
720
|
+
expect(res).to.be.equal("happy");
|
|
721
|
+
});
|
|
621
722
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
notDomain.prototype.addWSClient.call(ctx, 'key', 'happy');
|
|
628
|
-
expect(ctx._wsc.key).to.be.deep.equal('happy');
|
|
629
|
-
});
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
describe('WSClient', function() {
|
|
633
|
-
it('main exists', function() {
|
|
634
|
-
const ctx = {
|
|
635
|
-
_wsc:{
|
|
636
|
-
main: 'happy'
|
|
637
|
-
}
|
|
638
|
-
};
|
|
639
|
-
const res = notDomain.prototype.WSClient.call(ctx, 'main');
|
|
640
|
-
expect(res).to.be.equal('happy');
|
|
723
|
+
it("default(main) not exists", function () {
|
|
724
|
+
const dom = new notDomain({});
|
|
725
|
+
const res = dom.WSClient();
|
|
726
|
+
expect(res).to.be.undefined;
|
|
727
|
+
});
|
|
641
728
|
});
|
|
642
729
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
log(str){
|
|
664
|
-
expect(str).to.be.equal(`Перезагрузка сервиса через ${notDomain.OPT_DEFAULT_SHUTDOWN_TIMEOUT}мс...`)
|
|
665
|
-
},
|
|
666
|
-
emit(evName){
|
|
667
|
-
expect(evName).to.be.equal('app:shutdown');
|
|
668
|
-
}
|
|
669
|
-
};
|
|
670
|
-
notDomain.prototype.shutdown.call(ctx);
|
|
671
|
-
});
|
|
730
|
+
describe("shutdown", function () {
|
|
731
|
+
it(`default timeout, ${notDomain.OPT_DEFAULT_SHUTDOWN_TIMEOUT}ms`, function (done) {
|
|
732
|
+
const realProcess = process;
|
|
733
|
+
const exitMock = () => {
|
|
734
|
+
global.process = realProcess;
|
|
735
|
+
done();
|
|
736
|
+
};
|
|
737
|
+
global.process = { ...realProcess, exit: exitMock };
|
|
738
|
+
const ctx = {
|
|
739
|
+
log(str) {
|
|
740
|
+
expect(str).to.be.equal(
|
|
741
|
+
`Перезагрузка сервиса через ${notDomain.OPT_DEFAULT_SHUTDOWN_TIMEOUT}мс...`
|
|
742
|
+
);
|
|
743
|
+
},
|
|
744
|
+
emit(evName) {
|
|
745
|
+
expect(evName).to.be.equal("app:shutdown");
|
|
746
|
+
},
|
|
747
|
+
};
|
|
748
|
+
notDomain.prototype.shutdown.call(ctx);
|
|
749
|
+
});
|
|
672
750
|
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
751
|
+
it("custom timeout", function (done) {
|
|
752
|
+
const TIMEOUT = 1000;
|
|
753
|
+
const realProcess = process;
|
|
754
|
+
const exitMock = () => {
|
|
755
|
+
global.process = realProcess;
|
|
756
|
+
done();
|
|
757
|
+
};
|
|
758
|
+
global.process = { ...realProcess, exit: exitMock };
|
|
759
|
+
const ctx = {
|
|
760
|
+
log(str) {
|
|
761
|
+
expect(str).to.be.equal(
|
|
762
|
+
`Перезагрузка сервиса через ${TIMEOUT}мс...`
|
|
763
|
+
);
|
|
764
|
+
},
|
|
765
|
+
emit(evName) {
|
|
766
|
+
expect(evName).to.be.equal("app:shutdown");
|
|
767
|
+
},
|
|
768
|
+
};
|
|
769
|
+
notDomain.prototype.shutdown.call(ctx, TIMEOUT);
|
|
770
|
+
});
|
|
690
771
|
});
|
|
691
|
-
});
|
|
692
772
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
773
|
+
describe("getStatus", function () {
|
|
774
|
+
it("ok", function () {
|
|
775
|
+
const ctx = {
|
|
776
|
+
modules: {
|
|
777
|
+
"not-user": {
|
|
778
|
+
getStatus() {
|
|
779
|
+
return {
|
|
780
|
+
models: {
|
|
781
|
+
count: 2,
|
|
782
|
+
list: ["User", "Role"],
|
|
783
|
+
content: {},
|
|
784
|
+
},
|
|
785
|
+
routes: {
|
|
786
|
+
count: 2,
|
|
787
|
+
list: ["user", "role"],
|
|
788
|
+
content: {},
|
|
789
|
+
},
|
|
790
|
+
actions: {
|
|
791
|
+
count: 2,
|
|
792
|
+
list: ["user//list", "role//list"],
|
|
793
|
+
},
|
|
794
|
+
forms: {
|
|
795
|
+
count: 3,
|
|
796
|
+
list: [
|
|
797
|
+
"user//listAll",
|
|
798
|
+
"user//list",
|
|
799
|
+
"role//list",
|
|
800
|
+
],
|
|
801
|
+
},
|
|
802
|
+
};
|
|
803
|
+
},
|
|
804
|
+
},
|
|
805
|
+
},
|
|
806
|
+
getModule(name) {
|
|
807
|
+
return fModules[name];
|
|
808
|
+
},
|
|
809
|
+
};
|
|
810
|
+
const res = notDomain.prototype.getStatus.call(ctx);
|
|
811
|
+
expect(res).to.be.deep.equal({
|
|
812
|
+
modules: {
|
|
813
|
+
count: 1,
|
|
814
|
+
list: ["not-user"],
|
|
815
|
+
content: {
|
|
816
|
+
"not-user": {
|
|
817
|
+
models: {
|
|
818
|
+
count: 2,
|
|
819
|
+
list: ["User", "Role"],
|
|
820
|
+
content: {},
|
|
821
|
+
},
|
|
822
|
+
routes: {
|
|
823
|
+
count: 2,
|
|
824
|
+
list: ["user", "role"],
|
|
825
|
+
content: {},
|
|
826
|
+
},
|
|
827
|
+
actions: {
|
|
828
|
+
count: 2,
|
|
829
|
+
list: ["user//list", "role//list"],
|
|
830
|
+
},
|
|
831
|
+
forms: {
|
|
832
|
+
count: 3,
|
|
833
|
+
list: [
|
|
834
|
+
"user//listAll",
|
|
835
|
+
"user//list",
|
|
836
|
+
"role//list",
|
|
837
|
+
],
|
|
838
|
+
},
|
|
839
|
+
},
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
forms: {
|
|
843
|
+
count: 3,
|
|
844
|
+
list: [
|
|
845
|
+
"not-user//user//listAll",
|
|
846
|
+
"not-user//user//list",
|
|
847
|
+
"not-user//role//list",
|
|
848
|
+
],
|
|
705
849
|
},
|
|
706
850
|
routes: {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
851
|
+
count: 2,
|
|
852
|
+
list: ["not-user//user", "not-user//role"],
|
|
853
|
+
},
|
|
854
|
+
models: {
|
|
855
|
+
count: 2,
|
|
856
|
+
list: ["not-user//User", "not-user//Role"],
|
|
710
857
|
},
|
|
711
858
|
actions: {
|
|
712
|
-
|
|
713
|
-
|
|
859
|
+
count: 2,
|
|
860
|
+
list: ["not-user//user//list", "not-user//role//list"],
|
|
714
861
|
},
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
}
|
|
723
|
-
};
|
|
724
|
-
const res = notDomain.prototype.getStatus.call(ctx);
|
|
725
|
-
expect(res).to.be.deep.equal({
|
|
726
|
-
modules: {
|
|
727
|
-
count: 1,
|
|
728
|
-
list: ['not-user'],
|
|
729
|
-
content: {
|
|
730
|
-
'not-user':{
|
|
731
|
-
models: {
|
|
732
|
-
count: 2,
|
|
733
|
-
list: ['User', 'Role'],
|
|
734
|
-
content: {}
|
|
735
|
-
},
|
|
736
|
-
routes: {
|
|
737
|
-
count: 2,
|
|
738
|
-
list: ['user', 'role'],
|
|
739
|
-
content: {}
|
|
740
|
-
},
|
|
741
|
-
actions: {
|
|
742
|
-
count: 2,
|
|
743
|
-
list: ['user//list', 'role//list']
|
|
744
|
-
},
|
|
745
|
-
forms: {
|
|
746
|
-
count: 3,
|
|
747
|
-
list: ['user//listAll', 'user//list', 'role//list']
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
},
|
|
752
|
-
forms: {
|
|
753
|
-
count: 3,
|
|
754
|
-
list: ['not-user//user//listAll', 'not-user//user//list', 'not-user//role//list']
|
|
755
|
-
},
|
|
756
|
-
routes: {
|
|
757
|
-
count: 2,
|
|
758
|
-
list: ["not-user//user","not-user//role"]
|
|
759
|
-
},
|
|
760
|
-
models: {
|
|
761
|
-
count: 2,
|
|
762
|
-
list: ['not-user//User', 'not-user//Role']
|
|
763
|
-
},
|
|
764
|
-
actions: {
|
|
765
|
-
count: 2,
|
|
766
|
-
list: ['not-user//user//list', 'not-user//role//list']
|
|
767
|
-
},
|
|
768
|
-
roles: {
|
|
769
|
-
count: 0,
|
|
770
|
-
list: []
|
|
771
|
-
},
|
|
772
|
-
});
|
|
862
|
+
roles: {
|
|
863
|
+
count: 0,
|
|
864
|
+
list: [],
|
|
865
|
+
},
|
|
866
|
+
});
|
|
867
|
+
});
|
|
773
868
|
});
|
|
774
|
-
|
|
775
|
-
});
|
|
776
|
-
|
|
777
869
|
});
|