not-node 5.1.36 → 5.1.39

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/fields.js CHANGED
@@ -1,292 +1,297 @@
1
- const InitCore = require('../src/init/core');
1
+ const InitCore = require("../src/init/core");
2
2
 
3
- const expect = require('chai').expect,
4
- Fields = require('../src/fields');
3
+ const expect = require("chai").expect,
4
+ Fields = require("../src/fields");
5
5
 
6
-
7
- describe('Fields', function() {
8
- before(()=>{
9
- Fields.importFromDir(InitCore.paths.fields);
10
- });
11
-
12
- describe('registerField', function() {
13
-
14
- it('name not exists, value, options is not provided', function() {
15
- const fieldName = `field_name_${Math.random()}`;
16
- const fieldValue = {
17
- ui: {
18
- component: 'UITextfield'
19
- },
20
- model: {
21
- type: 'String'
22
- }
23
- };
24
- expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
25
- Fields.registerField(fieldName, fieldValue);
26
- expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
6
+ describe("Fields", function () {
7
+ before(() => {
8
+ Fields.importFromDir(InitCore.paths.fields);
27
9
  });
28
10
 
29
- it('name exists, value, options is not provided', function() {
30
- const fieldName = `field_name_${Math.random()}`;
31
- const fieldValue1 = {
32
- ui: {
33
- component: 'UITextfield'
34
- },
35
- model: {
36
- type: 'String'
37
- }
38
- };
39
- const fieldValue2 = {
40
- ui: {
41
- component: 'UISpecialField'
42
- },
43
- model: {
44
- type: 'StringNew',
45
- optimal: true
46
- }
47
- };
48
- expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
49
- Fields.registerField(fieldName, fieldValue1);
50
- expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
51
- Fields.registerField(fieldName, fieldValue2);
52
- expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue2);
53
- });
11
+ describe("registerField", function () {
12
+ it("name not exists, value, options is not provided", function () {
13
+ const fieldName = `field_name_${Math.random()}`;
14
+ const fieldValue = {
15
+ ui: {
16
+ component: "UITextfield",
17
+ },
18
+ model: {
19
+ type: "String",
20
+ },
21
+ };
22
+ expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
23
+ Fields.registerField(fieldName, fieldValue);
24
+ expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
25
+ });
54
26
 
55
- it('name exists, value, overwrite - true', function() {
56
- const fieldName = `field_name_${Math.random()}`;
57
- const fieldValue1 = {
58
- ui: {
59
- component: 'UITextfield'
60
- },
61
- model: {
62
- type: 'String'
63
- }
64
- };
65
- const fieldValue2 = {
66
- ui: {
67
- component: 'UISpecialField'
68
- },
69
- model: {
70
- type: 'StringNew',
71
- optimal: true
72
- }
73
- };
74
- expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
75
- Fields.registerField(fieldName, fieldValue1);
76
- expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
77
- Fields.registerField(fieldName, fieldValue2, {
78
- overwrite: true
79
- });
80
- expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue2);
81
- });
27
+ it("name exists, value, options is not provided", function () {
28
+ const fieldName = `field_name_${Math.random()}`;
29
+ const fieldValue1 = {
30
+ ui: {
31
+ component: "UITextfield",
32
+ },
33
+ model: {
34
+ type: "String",
35
+ },
36
+ };
37
+ const fieldValue2 = {
38
+ ui: {
39
+ component: "UISpecialField",
40
+ },
41
+ model: {
42
+ type: "StringNew",
43
+ optimal: true,
44
+ },
45
+ };
46
+ expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
47
+ Fields.registerField(fieldName, fieldValue1);
48
+ expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
49
+ Fields.registerField(fieldName, fieldValue2);
50
+ expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue2);
51
+ });
82
52
 
83
- it('name exists, value, overwrite - false, compose - false', function() {
84
- const fieldName = `field_name_${Math.random()}`;
85
- const fieldValue1 = {
86
- ui: {
87
- component: 'UITextfield'
88
- },
89
- model: {
90
- type: 'String'
91
- }
92
- };
93
- const fieldValue2 = {
94
- ui: {
95
- component: 'UISpecialField'
96
- },
97
- model: {
98
- type: 'StringNew',
99
- optimal: true
100
- }
101
- };
102
- expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
103
- Fields.registerField(fieldName, fieldValue1);
104
- expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
105
- Fields.registerField(fieldName, fieldValue2, {
106
- overwrite: false,
107
- compose: false
108
- });
109
- expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue1);
110
- });
111
- });
112
-
113
- describe('initFields', function() {
114
- it('list empty, type is not provided', () => {
115
- expect(Fields.initFields([])).to.be.deep.equal({});
116
- });
53
+ it("name exists, value, overwrite - true", function () {
54
+ const fieldName = `field_name_${Math.random()}`;
55
+ const fieldValue1 = {
56
+ ui: {
57
+ component: "UITextfield",
58
+ },
59
+ model: {
60
+ type: "String",
61
+ },
62
+ };
63
+ const fieldValue2 = {
64
+ ui: {
65
+ component: "UISpecialField",
66
+ },
67
+ model: {
68
+ type: "StringNew",
69
+ optimal: true,
70
+ },
71
+ };
72
+ expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
73
+ Fields.registerField(fieldName, fieldValue1);
74
+ expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
75
+ Fields.registerField(fieldName, fieldValue2, {
76
+ overwrite: true,
77
+ });
78
+ expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue2);
79
+ });
117
80
 
118
- it('list not empty, type is not provided', () => {
119
- expect(Fields.initFields(['title', 'uuid'])).to.be.deep.equal({
120
- title: {
121
- component: 'UITextfield',
122
- placeholder: 'core:field_title_placeholder',
123
- label: 'core:field_title_label'
124
- },
125
- uuid: {
126
- component: 'UITextfield',
127
- placeholder: 'core:field_UUID_placeholder',
128
- label: 'core:field_UUID_label',
129
- readonly: true
130
- }
131
- });
81
+ it("name exists, value, overwrite - false, compose - false", function () {
82
+ const fieldName = `field_name_${Math.random()}`;
83
+ const fieldValue1 = {
84
+ ui: {
85
+ component: "UITextfield",
86
+ },
87
+ model: {
88
+ type: "String",
89
+ },
90
+ };
91
+ const fieldValue2 = {
92
+ ui: {
93
+ component: "UISpecialField",
94
+ },
95
+ model: {
96
+ type: "StringNew",
97
+ optimal: true,
98
+ },
99
+ };
100
+ expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.false;
101
+ Fields.registerField(fieldName, fieldValue1);
102
+ expect(Object.keys(Fields.LIB).includes(fieldName)).to.be.true;
103
+ Fields.registerField(fieldName, fieldValue2, {
104
+ overwrite: false,
105
+ compose: false,
106
+ });
107
+ expect(Fields.LIB[fieldName]).to.be.deep.equal(fieldValue1);
108
+ });
132
109
  });
133
- });
134
110
 
111
+ describe("initFields", function () {
112
+ it("list empty, type is not provided", () => {
113
+ expect(Fields.initFields([])).to.be.deep.equal({});
114
+ });
135
115
 
136
- describe('initField', function() {
137
- it('field empty, resultOnly not provided, type not provided', () => {
138
- expect(Fields.initField('')).to.be.deep.equal({});
116
+ it("list not empty, type is not provided", () => {
117
+ expect(Fields.initFields(["title", "uuid"])).to.be.deep.equal({
118
+ title: {
119
+ component: "UITextfield",
120
+ placeholder: "core:field_title_placeholder",
121
+ label: "core:field_title_label",
122
+ },
123
+ uuid: {
124
+ component: "UITextfield",
125
+ placeholder: "core:field_UUID_placeholder",
126
+ label: "core:field_UUID_label",
127
+ readonly: true,
128
+ },
129
+ });
130
+ });
139
131
  });
140
132
 
141
- it('field, resultOnly not provided, type not provided', () => {
142
- expect(Fields.initField('title')).to.be.deep.equal({
143
- component: 'UITextfield',
144
- placeholder: 'core:field_title_placeholder',
145
- label: 'core:field_title_label'
146
- });
147
- });
133
+ describe("initField", function () {
134
+ it("field empty, resultOnly not provided, type not provided", () => {
135
+ expect(Fields.initField("")).to.be.deep.equal({});
136
+ });
148
137
 
149
- it('field, resultOnly - false, type not provided', () => {
150
- expect(Fields.initField('title', false)).to.be.deep.equal(['title', {
151
- component: 'UITextfield',
152
- placeholder: 'core:field_title_placeholder',
153
- label: 'core:field_title_label'
154
- }]);
155
- });
138
+ it("field, resultOnly not provided, type not provided", () => {
139
+ expect(Fields.initField("title")).to.be.deep.equal({
140
+ component: "UITextfield",
141
+ placeholder: "core:field_title_placeholder",
142
+ label: "core:field_title_label",
143
+ });
144
+ });
156
145
 
157
- it('field, resultOnly - false, type - model', () => {
158
- expect(Fields.initField('title', false, 'model')).to.be.deep.equal(['title', {
159
- type: String,
160
- required: true,
161
- searchable: true,
162
- sortable: true,
163
- safe: {
164
- update: ['@owner', 'root', 'admin'],
165
- read: ['@owner', 'root', 'admin']
166
- }
167
- }]);
168
- });
146
+ it("field, resultOnly - false, type not provided", () => {
147
+ expect(Fields.initField("title", false)).to.be.deep.equal([
148
+ "title",
149
+ {
150
+ component: "UITextfield",
151
+ placeholder: "core:field_title_placeholder",
152
+ label: "core:field_title_label",
153
+ },
154
+ ]);
155
+ });
169
156
 
157
+ it("field, resultOnly - false, type - model", () => {
158
+ expect(Fields.initField("title", false, "model")).to.be.deep.equal([
159
+ "title",
160
+ {
161
+ type: String,
162
+ required: true,
163
+ searchable: true,
164
+ sortable: true,
165
+ safe: {
166
+ update: ["@owner", "root", "admin"],
167
+ read: ["@owner", "root", "admin"],
168
+ },
169
+ },
170
+ ]);
171
+ });
170
172
 
171
- it('field - [src, mutation], resultOnly - false, type - model', () => {
172
- const field = [
173
- 'title',
174
- {
175
- sortable: false,
176
- safe: {
177
- update: ['*'],
178
- read: ['*'],
179
- }
180
- }
181
- ];
182
- expect(Fields.initField(field, false, 'model')).to.be.deep.equal(['title', {
183
- type: String,
184
- required: true,
185
- searchable: true,
186
- sortable: false,
187
- safe: {
188
- update: ['*'],
189
- read: ['*'],
190
- }
191
- }]);
192
- });
173
+ it("field - [src, mutation], resultOnly - false, type - model", () => {
174
+ const field = [
175
+ "title",
176
+ {
177
+ sortable: false,
178
+ safe: {
179
+ update: ["*"],
180
+ read: ["*"],
181
+ },
182
+ },
183
+ ];
184
+ expect(Fields.initField(field, false, "model")).to.be.deep.equal([
185
+ "title",
186
+ {
187
+ type: String,
188
+ required: true,
189
+ searchable: true,
190
+ sortable: false,
191
+ safe: {
192
+ update: ["*"],
193
+ read: ["*"],
194
+ },
195
+ },
196
+ ]);
197
+ });
193
198
 
194
- it('field - [dest, mutation, src], resultOnly - false, type - model', () => {
195
- const field = [
196
- 'titleOfBilbao',
197
- {
198
- sortable: false,
199
- safe: {
200
- update: ['*'],
201
- read: ['*'],
202
- }
203
- },
204
- 'title'
205
- ];
206
- expect(Fields.initField(field, false, 'model')).to.be.deep.equal(['titleOfBilbao', {
207
- type: String,
208
- required: true,
209
- searchable: true,
210
- sortable: false,
211
- safe: {
212
- update: ['*'],
213
- read: ['*'],
214
- }
215
- }]);
199
+ it("field - [dest, mutation, src], resultOnly - false, type - model", () => {
200
+ const field = [
201
+ "titleOfBilbao",
202
+ {
203
+ sortable: false,
204
+ safe: {
205
+ update: ["*"],
206
+ read: ["*"],
207
+ },
208
+ },
209
+ "title",
210
+ ];
211
+ expect(Fields.initField(field, false, "model")).to.be.deep.equal([
212
+ "titleOfBilbao",
213
+ {
214
+ type: String,
215
+ required: true,
216
+ searchable: true,
217
+ sortable: false,
218
+ safe: {
219
+ update: ["*"],
220
+ read: ["*"],
221
+ },
222
+ },
223
+ ]);
224
+ });
216
225
  });
217
- });
218
226
 
219
- describe('getMutationForField', function() {
220
- it('name and list supplied, list contains name', () => {
221
- const list = [
222
- 'tite',
223
- ['tile'],
224
- ['title', {mutant: true}]
225
- ];
226
- expect(Fields.getMutationForField('title', list)).to.be.deep.equal(['title', {mutant: true}]);
227
- });
227
+ describe("getMutationForField", function () {
228
+ it("name and list supplied, list contains name", () => {
229
+ const list = ["tite", ["tile"], ["title", { mutant: true }]];
230
+ expect(Fields.getMutationForField("title", list)).to.be.deep.equal([
231
+ "title",
232
+ { mutant: true },
233
+ ]);
234
+ });
228
235
 
229
- it('name and list supplied, list doesnt contain name', () => {
230
- const list = [
231
- 'tite',
232
- ['tile'],
233
- ['title', {mutant: true}]
234
- ];
235
- expect(Fields.getMutationForField('titler', list)).to.be.deep.equal(false);
236
+ it("name and list supplied, list doesnt contain name", () => {
237
+ const list = ["tite", ["tile"], ["title", { mutant: true }]];
238
+ expect(Fields.getMutationForField("titler", list)).to.be.deep.equal(
239
+ false
240
+ );
241
+ });
236
242
  });
237
- });
238
243
 
239
- describe('fromSchema', function() {
240
- it('schema(title, uuid), rawMutationsList = []', () => {
241
- const schema = {
242
- title:{},
243
- uuid: {},
244
- };
245
- expect(Fields.fromSchema(schema)).to.be.deep.equal({
246
- title:{
247
- component: 'UITextfield',
248
- placeholder: 'core:field_title_placeholder',
249
- label: 'core:field_title_label'
250
- },
251
- uuid:{
252
- component: 'UITextfield',
253
- placeholder: 'core:field_UUID_placeholder',
254
- label: 'core:field_UUID_label',
255
- readonly: true
256
- }
257
- });
258
- });
244
+ describe("fromSchema", function () {
245
+ it("schema(title, uuid), rawMutationsList = []", () => {
246
+ const schema = {
247
+ title: {},
248
+ uuid: {},
249
+ };
250
+ expect(Fields.fromSchema(schema)).to.be.deep.equal({
251
+ title: {
252
+ component: "UITextfield",
253
+ placeholder: "core:field_title_placeholder",
254
+ label: "core:field_title_label",
255
+ },
256
+ uuid: {
257
+ component: "UITextfield",
258
+ placeholder: "core:field_UUID_placeholder",
259
+ label: "core:field_UUID_label",
260
+ readonly: true,
261
+ },
262
+ });
263
+ });
259
264
 
260
- it('schema - empty, rawMutationsList = []', () => {
261
- expect(Fields.fromSchema('')).to.be.deep.equal({});
262
- });
265
+ it("schema - empty, rawMutationsList = []", () => {
266
+ expect(Fields.fromSchema("")).to.be.deep.equal({});
267
+ });
263
268
 
264
- it('schema(title, uuid), rawMutationsList = []', () => {
265
- const schema = {
266
- title:{},
267
- uuid: {},
268
- };
269
- const mutations = [
270
- ['title', {
271
- label: 'Naming'
272
- }]
273
- ];
274
- expect(Fields.fromSchema(schema,mutations)).to.be.deep.equal({
275
- title:{
276
- component: 'UITextfield',
277
- placeholder: 'core:field_title_placeholder',
278
- label: 'Naming'
279
- },
280
- uuid:{
281
- component: 'UITextfield',
282
- placeholder: 'core:field_UUID_placeholder',
283
- label: 'core:field_UUID_label',
284
- readonly: true
285
- }
286
- });
269
+ it("schema(title, uuid), rawMutationsList = []", () => {
270
+ const schema = {
271
+ title: {},
272
+ uuid: {},
273
+ };
274
+ const mutations = [
275
+ [
276
+ "title",
277
+ {
278
+ label: "Naming",
279
+ },
280
+ ],
281
+ ];
282
+ expect(Fields.fromSchema(schema, mutations)).to.be.deep.equal({
283
+ title: {
284
+ component: "UITextfield",
285
+ placeholder: "core:field_title_placeholder",
286
+ label: "Naming",
287
+ },
288
+ uuid: {
289
+ component: "UITextfield",
290
+ placeholder: "core:field_UUID_placeholder",
291
+ label: "core:field_UUID_label",
292
+ readonly: true,
293
+ },
294
+ });
295
+ });
287
296
  });
288
- });
289
-
290
-
291
-
292
297
  });