@nymphjs/nymph 1.0.0-beta.4 → 1.0.0-beta.41
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/CHANGELOG.md +195 -0
- package/README.md +12 -12
- package/dist/Entity.d.ts +24 -3
- package/dist/Entity.js +194 -86
- package/dist/Entity.js.map +1 -1
- package/dist/Entity.test.js +34 -17
- package/dist/Entity.test.js.map +1 -1
- package/dist/Entity.types.d.ts +3 -1
- package/dist/Nymph.d.ts +22 -7
- package/dist/Nymph.js +214 -68
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +18 -5
- package/dist/Nymph.types.js +1 -1
- package/dist/Nymph.types.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +1 -22
- package/dist/driver/NymphDriver.js +2 -16
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/testArtifacts.js +208 -159
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/errors/InvalidStateError.d.ts +3 -0
- package/dist/errors/InvalidStateError.js +11 -0
- package/dist/errors/InvalidStateError.js.map +1 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +1 -0
- package/dist/errors/index.js.map +1 -1
- package/dist/testArtifacts.d.ts +10 -3
- package/dist/testArtifacts.js +20 -11
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.d.ts +10 -7
- package/dist/testMocks.js +22 -10
- package/dist/testMocks.js.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +11 -5
- package/dist/utils.js.map +1 -1
- package/package.json +13 -13
- package/src/Entity.test.ts +31 -9
- package/src/Entity.ts +289 -113
- package/src/Entity.types.ts +13 -1
- package/src/Nymph.ts +386 -82
- package/src/Nymph.types.ts +76 -5
- package/src/driver/NymphDriver.ts +19 -85
- package/src/driver/testArtifacts.ts +125 -44
- package/src/errors/InvalidStateError.ts +6 -0
- package/src/errors/index.ts +2 -0
- package/src/testArtifacts.ts +28 -10
- package/src/testMocks.ts +38 -21
- package/src/utils.ts +21 -7
- package/typedoc.json +4 -0
|
@@ -9,8 +9,9 @@ const strtotime_1 = __importDefault(require("locutus/php/datetime/strtotime"));
|
|
|
9
9
|
const guid_1 = require("@nymphjs/guid");
|
|
10
10
|
const testArtifacts_1 = require("../testArtifacts");
|
|
11
11
|
function QueriesTest(nymph, it) {
|
|
12
|
-
nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
13
|
-
nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
12
|
+
const TestModel = nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
13
|
+
const TestBModel = nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
14
|
+
const TestEmptyModel = nymph.addEntityClass(testArtifacts_1.TestEmptyModel);
|
|
14
15
|
let testEntity;
|
|
15
16
|
let testGuid;
|
|
16
17
|
let refGuid;
|
|
@@ -19,7 +20,7 @@ function QueriesTest(nymph, it) {
|
|
|
19
20
|
if (testGuid != null) {
|
|
20
21
|
return;
|
|
21
22
|
}
|
|
22
|
-
testEntity = await
|
|
23
|
+
testEntity = await TestModel.factory();
|
|
23
24
|
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
24
25
|
testEntity.null = null;
|
|
25
26
|
testEntity.string = 'test';
|
|
@@ -28,14 +29,17 @@ function QueriesTest(nymph, it) {
|
|
|
28
29
|
|
|
29
30
|
This one's email address is nice_hat-wednesday+newyork@im-a-hat.hat.
|
|
30
31
|
This one's phone number is (555) 555-1818.
|
|
31
|
-
This one's zip code is 92064
|
|
32
|
+
This one's zip code is 92064.
|
|
33
|
+
This one's favorite emojis are 🔥❤️😊😂⭐🤔
|
|
34
|
+
|
|
35
|
+
These hats are absolutely fantastic.`;
|
|
32
36
|
testEntity.number = 30;
|
|
33
37
|
testEntity.numberString = '30';
|
|
34
38
|
testEntity.timestamp = Date.now();
|
|
35
39
|
expect(await testEntity.$save()).toEqual(true);
|
|
36
40
|
expect(testEntity.guid).not.toBeNull();
|
|
37
41
|
testGuid = testEntity.guid;
|
|
38
|
-
const entityReferenceTest = new
|
|
42
|
+
const entityReferenceTest = new TestModel();
|
|
39
43
|
entityReferenceTest.string = 'wrong';
|
|
40
44
|
entityReferenceTest.timestamp = (0, strtotime_1.default)('-2 days') * 1000;
|
|
41
45
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
@@ -45,19 +49,17 @@ This one's zip code is 92064.`;
|
|
|
45
49
|
expect(await testEntity.$save()).toEqual(true);
|
|
46
50
|
entityReferenceTest.test = 'good';
|
|
47
51
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
48
|
-
testEntity = nymph.
|
|
49
|
-
expect(testEntity).toBeInstanceOf(
|
|
50
|
-
expect(testEntity.guid).toEqual(testGuid);
|
|
51
|
-
testEntity = (await nymph.getEntity({ class: testArtifacts_1.TestModel }, testGuid));
|
|
52
|
-
expect(testEntity).toBeInstanceOf(testArtifacts_1.TestModel);
|
|
52
|
+
testEntity = (await nymph.getEntity({ class: TestModel }, testGuid));
|
|
53
|
+
expect(testEntity).toBeInstanceOf(TestModel);
|
|
53
54
|
expect(testEntity.guid).toEqual(testGuid);
|
|
54
55
|
}
|
|
55
56
|
async function createMultipleTestEntities() {
|
|
56
57
|
if (!createdMultiple) {
|
|
57
58
|
createdMultiple = true;
|
|
58
59
|
for (let i = 0; i < 100; i++) {
|
|
59
|
-
const testEntity = await
|
|
60
|
+
const testEntity = await TestModel.factory();
|
|
60
61
|
testEntity.name = `Multi Test ${i}`;
|
|
62
|
+
testEntity.number = 100 - i;
|
|
61
63
|
testEntity.$removeTag('test');
|
|
62
64
|
testEntity.$addTag('multiTest');
|
|
63
65
|
expect(await testEntity.$save()).toEqual(true);
|
|
@@ -66,17 +68,22 @@ This one's zip code is 92064.`;
|
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
it('delete old test data', async () => {
|
|
69
|
-
let all = await nymph.getEntities({ class:
|
|
71
|
+
let all = await nymph.getEntities({ class: TestModel });
|
|
70
72
|
expect(Array.isArray(all)).toEqual(true);
|
|
71
73
|
for (const cur of all) {
|
|
72
74
|
expect(await cur.$delete()).toEqual(true);
|
|
73
75
|
}
|
|
74
|
-
all = await nymph.getEntities({ class:
|
|
76
|
+
all = await nymph.getEntities({ class: TestModel });
|
|
75
77
|
expect(all.length).toEqual(0);
|
|
76
78
|
});
|
|
77
79
|
it('create entity', async () => {
|
|
78
80
|
await createTestEntities();
|
|
79
81
|
});
|
|
82
|
+
it("doesn't create empty entity", async () => {
|
|
83
|
+
const testEntity = await TestEmptyModel.factory();
|
|
84
|
+
expect(await testEntity.$save()).toBeFalsy();
|
|
85
|
+
expect(testEntity.guid).toBeNull();
|
|
86
|
+
});
|
|
80
87
|
it('update mdate on save', async () => {
|
|
81
88
|
await createTestEntities();
|
|
82
89
|
const oldMdate = testEntity.mdate ?? Infinity;
|
|
@@ -89,11 +96,11 @@ This one's zip code is 92064.`;
|
|
|
89
96
|
});
|
|
90
97
|
it('by guid', async () => {
|
|
91
98
|
await createTestEntities();
|
|
92
|
-
let resultEntity = await nymph.getEntity({ class:
|
|
99
|
+
let resultEntity = await nymph.getEntity({ class: TestModel }, testGuid);
|
|
93
100
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
94
|
-
resultEntity = await
|
|
101
|
+
resultEntity = await TestModel.factory(testGuid);
|
|
95
102
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
96
|
-
resultEntity = await nymph.getEntity({ class:
|
|
103
|
+
resultEntity = await nymph.getEntity({ class: TestModel }, (0, guid_1.guid)());
|
|
97
104
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
98
105
|
});
|
|
99
106
|
it('transactions', async () => {
|
|
@@ -116,18 +123,18 @@ This one's zip code is 92064.`;
|
|
|
116
123
|
testEntity.$nymph = transaction;
|
|
117
124
|
expect(await transaction.inTransaction()).toEqual(true);
|
|
118
125
|
expect(await testEntity.$delete()).toEqual(true);
|
|
119
|
-
const resultEntity = await transaction.getEntity({ class:
|
|
126
|
+
const resultEntity = await transaction.getEntity({ class: TestModel }, testGuid);
|
|
120
127
|
expect(resultEntity).toBeNull();
|
|
121
128
|
await transaction.rollback('test');
|
|
122
129
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
123
|
-
testEntity = (await transaction.getEntity({ class:
|
|
130
|
+
testEntity = (await transaction.getEntity({ class: TestModel }, testGuid));
|
|
124
131
|
expect(testEntity.guid).toEqual(testGuid);
|
|
125
|
-
transaction = await nymph.startTransaction('test');
|
|
132
|
+
transaction = await nymph.startTransaction('test.1');
|
|
126
133
|
testEntity.$nymph = transaction;
|
|
127
134
|
expect(await transaction.inTransaction()).toEqual(true);
|
|
128
135
|
testEntity.string = 'fish';
|
|
129
136
|
expect(await testEntity.$save()).toEqual(true);
|
|
130
|
-
await transaction.commit('test');
|
|
137
|
+
await transaction.commit('test.1');
|
|
131
138
|
testEntity.$nymph = nymph;
|
|
132
139
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
133
140
|
await testEntity.$refresh();
|
|
@@ -138,7 +145,7 @@ This one's zip code is 92064.`;
|
|
|
138
145
|
it('options', async () => {
|
|
139
146
|
await createTestEntities();
|
|
140
147
|
const resultEntities = await nymph.getEntities({
|
|
141
|
-
class:
|
|
148
|
+
class: TestModel,
|
|
142
149
|
reverse: true,
|
|
143
150
|
offset: 1,
|
|
144
151
|
limit: 1,
|
|
@@ -149,174 +156,174 @@ This one's zip code is 92064.`;
|
|
|
149
156
|
});
|
|
150
157
|
it('guid and tags', async () => {
|
|
151
158
|
await createTestEntities();
|
|
152
|
-
const resultEntity = await nymph.getEntity({ class:
|
|
159
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid, tag: 'test' });
|
|
153
160
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
154
161
|
});
|
|
155
162
|
it('or selector', async () => {
|
|
156
163
|
await createTestEntities();
|
|
157
|
-
const resultEntity = await nymph.getEntity({ class:
|
|
164
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '|', guid: [testGuid, (0, guid_1.guid)()] });
|
|
158
165
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
159
166
|
});
|
|
160
167
|
it('wrong or selector', async () => {
|
|
161
168
|
await createTestEntities();
|
|
162
|
-
const resultEntity = await nymph.getEntity({ class:
|
|
169
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '|', guid: [(0, guid_1.guid)(), (0, guid_1.guid)()] });
|
|
163
170
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
164
171
|
});
|
|
165
172
|
it('not guid', async () => {
|
|
166
173
|
await createTestEntities();
|
|
167
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
174
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', '!guid': (0, guid_1.guid)(), tag: 'test' });
|
|
168
175
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
169
176
|
});
|
|
170
177
|
it('not tags', async () => {
|
|
171
178
|
await createTestEntities();
|
|
172
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
179
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] });
|
|
173
180
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
174
181
|
});
|
|
175
182
|
it('guid and wrong tags', async () => {
|
|
176
183
|
await createTestEntities();
|
|
177
|
-
const resultEntity = await nymph.getEntity({ class:
|
|
184
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid, tag: ['pickles'] });
|
|
178
185
|
expect(resultEntity).toBeNull();
|
|
179
186
|
});
|
|
180
187
|
it('tags', async () => {
|
|
181
188
|
await createTestEntities();
|
|
182
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
189
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' });
|
|
183
190
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
184
191
|
});
|
|
185
192
|
it('wrong tags', async () => {
|
|
186
193
|
await createTestEntities();
|
|
187
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
194
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles' });
|
|
188
195
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
189
196
|
});
|
|
190
197
|
it('inclusive tags', async () => {
|
|
191
198
|
await createTestEntities();
|
|
192
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
199
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '|', tag: ['pickles', 'test', 'barbecue'] });
|
|
193
200
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
194
201
|
});
|
|
195
202
|
it('wrong inclusive tags', async () => {
|
|
196
203
|
await createTestEntities();
|
|
197
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
204
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '|', tag: ['pickles', 'barbecue'] });
|
|
198
205
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
199
206
|
});
|
|
200
207
|
it('mixed tags', async () => {
|
|
201
208
|
await createTestEntities();
|
|
202
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
209
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', tag: ['pickles', 'test', 'barbecue'] });
|
|
203
210
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
204
211
|
});
|
|
205
212
|
it('wrong inclusive mixed tags', async () => {
|
|
206
213
|
await createTestEntities();
|
|
207
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
214
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', tag: ['pickles', 'barbecue'] });
|
|
208
215
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
209
216
|
});
|
|
210
217
|
it('wrong exclusive mixed tags', async () => {
|
|
211
218
|
await createTestEntities();
|
|
212
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
219
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles' }, { type: '|', tag: ['test', 'barbecue'] });
|
|
213
220
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
214
221
|
});
|
|
215
222
|
it('defined', async () => {
|
|
216
223
|
await createTestEntities();
|
|
217
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
224
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', defined: 'string' });
|
|
218
225
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
219
226
|
});
|
|
220
227
|
it('not defined', async () => {
|
|
221
228
|
await createTestEntities();
|
|
222
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
229
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!defined': 'pickles' });
|
|
223
230
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
224
231
|
});
|
|
225
232
|
it('defined in a not and clause', async () => {
|
|
226
233
|
await createTestEntities();
|
|
227
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
234
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '!&', defined: 'pickles' }, { type: '&', tag: 'test' });
|
|
228
235
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
229
236
|
});
|
|
230
237
|
it('equal', async () => {
|
|
231
238
|
await createTestEntities();
|
|
232
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
239
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', equal: ['string', 'test'] });
|
|
233
240
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
234
241
|
});
|
|
235
242
|
it('not equal', async () => {
|
|
236
243
|
await createTestEntities();
|
|
237
|
-
const referenceEntity = await
|
|
244
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
238
245
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
239
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
246
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!equal': ['string', 'wrong'] });
|
|
240
247
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
241
248
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
242
249
|
});
|
|
243
250
|
it('like', async () => {
|
|
244
251
|
await createTestEntities();
|
|
245
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
252
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', like: ['string', 't_s%'] });
|
|
246
253
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
247
254
|
});
|
|
248
255
|
it('not like', async () => {
|
|
249
256
|
await createTestEntities();
|
|
250
|
-
const referenceEntity = await
|
|
257
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
251
258
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
252
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
259
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!like': ['string', 'wr_n%'] });
|
|
253
260
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
254
261
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
255
262
|
});
|
|
256
263
|
it('ilike', async () => {
|
|
257
264
|
await createTestEntities();
|
|
258
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
265
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ilike: ['string', 'T_s%'] });
|
|
259
266
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
260
267
|
});
|
|
261
268
|
it('not ilike', async () => {
|
|
262
269
|
await createTestEntities();
|
|
263
|
-
const referenceEntity = await
|
|
270
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
264
271
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
265
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
272
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] });
|
|
266
273
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
267
274
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
268
275
|
});
|
|
269
276
|
it('like with wrong case', async () => {
|
|
270
277
|
await createTestEntities();
|
|
271
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
278
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', like: ['string', 'T_s%'] });
|
|
272
279
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
273
280
|
});
|
|
274
281
|
it('tags and equal', async () => {
|
|
275
282
|
await createTestEntities();
|
|
276
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
283
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', equal: ['string', 'test'] });
|
|
277
284
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
278
285
|
});
|
|
279
286
|
it('wrong tags right equal', async () => {
|
|
280
287
|
await createTestEntities();
|
|
281
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
288
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles', equal: ['string', 'test'] });
|
|
282
289
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
283
290
|
});
|
|
284
291
|
it('right tags wrong equal', async () => {
|
|
285
292
|
await createTestEntities();
|
|
286
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
293
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', equal: ['string', 'pickles'] });
|
|
287
294
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
288
295
|
});
|
|
289
296
|
it('wrong tags wrong equal', async () => {
|
|
290
297
|
await createTestEntities();
|
|
291
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
298
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles', equal: ['string', 'pickles'] });
|
|
292
299
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
293
300
|
});
|
|
294
301
|
it('contain', async () => {
|
|
295
302
|
await createTestEntities();
|
|
296
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
303
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 'values'] });
|
|
297
304
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
298
|
-
resultEntity = await nymph.getEntities({ class:
|
|
305
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['string', 'test'] });
|
|
299
306
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
300
307
|
});
|
|
301
308
|
it('not contain', async () => {
|
|
302
309
|
await createTestEntities();
|
|
303
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
310
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', contain: ['array', 'pickles'] });
|
|
304
311
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
305
312
|
});
|
|
306
313
|
it('wrong contain', async () => {
|
|
307
314
|
await createTestEntities();
|
|
308
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
315
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 'pickles'] });
|
|
309
316
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
310
|
-
resultEntity = await nymph.getEntities({ class:
|
|
317
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['string', 'pickles'] });
|
|
311
318
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
312
319
|
});
|
|
313
320
|
it('match', async () => {
|
|
314
321
|
await createTestEntities();
|
|
315
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
322
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', match: ['match', '.*'] });
|
|
316
323
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
317
|
-
resultEntity = await nymph.getEntities({ class:
|
|
324
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', match: ['match', 'Edward McCheese'] });
|
|
318
325
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
319
|
-
resultEntity = await nymph.getEntities({ class:
|
|
326
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, {
|
|
320
327
|
type: '|',
|
|
321
328
|
match: [
|
|
322
329
|
['string', '[0-9]'],
|
|
@@ -324,13 +331,13 @@ This one's zip code is 92064.`;
|
|
|
324
331
|
],
|
|
325
332
|
});
|
|
326
333
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
327
|
-
resultEntity = await nymph.getEntities({ class:
|
|
334
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
328
335
|
type: '&',
|
|
329
336
|
tag: 'test',
|
|
330
337
|
match: ['match', '[-a-zA-Z0-9+_]+@[-a-zA-Z0-9_]+.[-a-zA-Z0-9_]{2,4}'],
|
|
331
338
|
});
|
|
332
339
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
333
|
-
resultEntity = await nymph.getEntities({ class:
|
|
340
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
334
341
|
type: '&',
|
|
335
342
|
tag: 'test',
|
|
336
343
|
match: ['match', '\\([0-9]{3}\\) [0-9]{3}-[0-9]{4}'],
|
|
@@ -339,16 +346,16 @@ This one's zip code is 92064.`;
|
|
|
339
346
|
});
|
|
340
347
|
it('imatch', async () => {
|
|
341
348
|
await createTestEntities();
|
|
342
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
349
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] });
|
|
343
350
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
344
351
|
});
|
|
345
352
|
it('wrong match', async () => {
|
|
346
353
|
await createTestEntities();
|
|
347
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
354
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', match: ['match', 'Q'] });
|
|
348
355
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
349
|
-
resultEntity = await nymph.getEntities({ class:
|
|
356
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickle', match: ['match', '.*'] });
|
|
350
357
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
351
|
-
resultEntity = await nymph.getEntities({ class:
|
|
358
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
352
359
|
type: '|',
|
|
353
360
|
match: [
|
|
354
361
|
['string', '[0-9]'],
|
|
@@ -359,17 +366,17 @@ This one's zip code is 92064.`;
|
|
|
359
366
|
});
|
|
360
367
|
it('match wrong case', async () => {
|
|
361
368
|
await createTestEntities();
|
|
362
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
369
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', match: ['match', 'edward mccheese'] });
|
|
363
370
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
364
371
|
});
|
|
365
372
|
it('match and equal inclusive', async () => {
|
|
366
373
|
await createTestEntities();
|
|
367
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
374
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', equal: ['string', 'pickles'], match: ['string', 'test'] });
|
|
368
375
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
369
376
|
});
|
|
370
377
|
it('greater than', async () => {
|
|
371
378
|
await createTestEntities();
|
|
372
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
379
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
373
380
|
type: '|',
|
|
374
381
|
gt: [
|
|
375
382
|
['number', 30],
|
|
@@ -377,7 +384,7 @@ This one's zip code is 92064.`;
|
|
|
377
384
|
],
|
|
378
385
|
});
|
|
379
386
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
380
|
-
resultEntity = await nymph.getEntities({ class:
|
|
387
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
381
388
|
type: '|',
|
|
382
389
|
gt: [
|
|
383
390
|
['number', 31],
|
|
@@ -385,7 +392,7 @@ This one's zip code is 92064.`;
|
|
|
385
392
|
],
|
|
386
393
|
});
|
|
387
394
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
388
|
-
resultEntity = await nymph.getEntities({ class:
|
|
395
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
389
396
|
type: '|',
|
|
390
397
|
gt: [
|
|
391
398
|
['number', 29],
|
|
@@ -393,7 +400,7 @@ This one's zip code is 92064.`;
|
|
|
393
400
|
],
|
|
394
401
|
});
|
|
395
402
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
396
|
-
resultEntity = await nymph.getEntities({ class:
|
|
403
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
397
404
|
type: '|',
|
|
398
405
|
gt: [
|
|
399
406
|
['numberString', 30],
|
|
@@ -401,7 +408,7 @@ This one's zip code is 92064.`;
|
|
|
401
408
|
],
|
|
402
409
|
});
|
|
403
410
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
404
|
-
resultEntity = await nymph.getEntities({ class:
|
|
411
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
405
412
|
type: '|',
|
|
406
413
|
gt: [
|
|
407
414
|
['numberString', 31],
|
|
@@ -409,7 +416,7 @@ This one's zip code is 92064.`;
|
|
|
409
416
|
],
|
|
410
417
|
});
|
|
411
418
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
412
|
-
resultEntity = await nymph.getEntities({ class:
|
|
419
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
413
420
|
type: '|',
|
|
414
421
|
gt: [
|
|
415
422
|
['numberString', 29],
|
|
@@ -420,7 +427,7 @@ This one's zip code is 92064.`;
|
|
|
420
427
|
});
|
|
421
428
|
it('greater than or equal', async () => {
|
|
422
429
|
await createTestEntities();
|
|
423
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
430
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
424
431
|
type: '|',
|
|
425
432
|
gte: [
|
|
426
433
|
['number', 30],
|
|
@@ -428,7 +435,7 @@ This one's zip code is 92064.`;
|
|
|
428
435
|
],
|
|
429
436
|
});
|
|
430
437
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
431
|
-
resultEntity = await nymph.getEntities({ class:
|
|
438
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
432
439
|
type: '|',
|
|
433
440
|
gte: [
|
|
434
441
|
['number', 31],
|
|
@@ -436,7 +443,7 @@ This one's zip code is 92064.`;
|
|
|
436
443
|
],
|
|
437
444
|
});
|
|
438
445
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
439
|
-
resultEntity = await nymph.getEntities({ class:
|
|
446
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
440
447
|
type: '|',
|
|
441
448
|
gte: [
|
|
442
449
|
['number', 29],
|
|
@@ -444,7 +451,7 @@ This one's zip code is 92064.`;
|
|
|
444
451
|
],
|
|
445
452
|
});
|
|
446
453
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
447
|
-
resultEntity = await nymph.getEntities({ class:
|
|
454
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
448
455
|
type: '|',
|
|
449
456
|
gte: [
|
|
450
457
|
['numberString', 30],
|
|
@@ -452,7 +459,7 @@ This one's zip code is 92064.`;
|
|
|
452
459
|
],
|
|
453
460
|
});
|
|
454
461
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
455
|
-
resultEntity = await nymph.getEntities({ class:
|
|
462
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
456
463
|
type: '|',
|
|
457
464
|
gte: [
|
|
458
465
|
['numberString', 31],
|
|
@@ -460,7 +467,7 @@ This one's zip code is 92064.`;
|
|
|
460
467
|
],
|
|
461
468
|
});
|
|
462
469
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
463
|
-
resultEntity = await nymph.getEntities({ class:
|
|
470
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
464
471
|
type: '|',
|
|
465
472
|
gte: [
|
|
466
473
|
['numberString', 29],
|
|
@@ -471,7 +478,7 @@ This one's zip code is 92064.`;
|
|
|
471
478
|
});
|
|
472
479
|
it('less than', async () => {
|
|
473
480
|
await createTestEntities();
|
|
474
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
481
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
475
482
|
type: '|',
|
|
476
483
|
lt: [
|
|
477
484
|
['number', 30],
|
|
@@ -479,7 +486,7 @@ This one's zip code is 92064.`;
|
|
|
479
486
|
],
|
|
480
487
|
});
|
|
481
488
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
482
|
-
resultEntity = await nymph.getEntities({ class:
|
|
489
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
483
490
|
type: '|',
|
|
484
491
|
lt: [
|
|
485
492
|
['number', 31],
|
|
@@ -487,7 +494,7 @@ This one's zip code is 92064.`;
|
|
|
487
494
|
],
|
|
488
495
|
});
|
|
489
496
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
490
|
-
resultEntity = await nymph.getEntities({ class:
|
|
497
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
491
498
|
type: '|',
|
|
492
499
|
lt: [
|
|
493
500
|
['number', 29],
|
|
@@ -495,7 +502,7 @@ This one's zip code is 92064.`;
|
|
|
495
502
|
],
|
|
496
503
|
});
|
|
497
504
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
498
|
-
resultEntity = await nymph.getEntities({ class:
|
|
505
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
499
506
|
type: '|',
|
|
500
507
|
lt: [
|
|
501
508
|
['numberString', 30],
|
|
@@ -503,7 +510,7 @@ This one's zip code is 92064.`;
|
|
|
503
510
|
],
|
|
504
511
|
});
|
|
505
512
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
506
|
-
resultEntity = await nymph.getEntities({ class:
|
|
513
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
507
514
|
type: '|',
|
|
508
515
|
lt: [
|
|
509
516
|
['numberString', 31],
|
|
@@ -511,7 +518,7 @@ This one's zip code is 92064.`;
|
|
|
511
518
|
],
|
|
512
519
|
});
|
|
513
520
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
514
|
-
resultEntity = await nymph.getEntities({ class:
|
|
521
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
515
522
|
type: '|',
|
|
516
523
|
lt: [
|
|
517
524
|
['numberString', 29],
|
|
@@ -522,7 +529,7 @@ This one's zip code is 92064.`;
|
|
|
522
529
|
});
|
|
523
530
|
it('less than or equal', async () => {
|
|
524
531
|
await createTestEntities();
|
|
525
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
532
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
526
533
|
type: '|',
|
|
527
534
|
lte: [
|
|
528
535
|
['number', 30],
|
|
@@ -530,7 +537,7 @@ This one's zip code is 92064.`;
|
|
|
530
537
|
],
|
|
531
538
|
});
|
|
532
539
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
533
|
-
resultEntity = await nymph.getEntities({ class:
|
|
540
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
534
541
|
type: '|',
|
|
535
542
|
lte: [
|
|
536
543
|
['number', 31],
|
|
@@ -538,7 +545,7 @@ This one's zip code is 92064.`;
|
|
|
538
545
|
],
|
|
539
546
|
});
|
|
540
547
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
541
|
-
resultEntity = await nymph.getEntities({ class:
|
|
548
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
542
549
|
type: '|',
|
|
543
550
|
lte: [
|
|
544
551
|
['number', 29],
|
|
@@ -546,7 +553,7 @@ This one's zip code is 92064.`;
|
|
|
546
553
|
],
|
|
547
554
|
});
|
|
548
555
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
549
|
-
resultEntity = await nymph.getEntities({ class:
|
|
556
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
550
557
|
type: '|',
|
|
551
558
|
lte: [
|
|
552
559
|
['numberString', 30],
|
|
@@ -554,7 +561,7 @@ This one's zip code is 92064.`;
|
|
|
554
561
|
],
|
|
555
562
|
});
|
|
556
563
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
557
|
-
resultEntity = await nymph.getEntities({ class:
|
|
564
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
558
565
|
type: '|',
|
|
559
566
|
lte: [
|
|
560
567
|
['numberString', 31],
|
|
@@ -562,7 +569,7 @@ This one's zip code is 92064.`;
|
|
|
562
569
|
],
|
|
563
570
|
});
|
|
564
571
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
565
|
-
resultEntity = await nymph.getEntities({ class:
|
|
572
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
566
573
|
type: '|',
|
|
567
574
|
lte: [
|
|
568
575
|
['numberString', 29],
|
|
@@ -573,31 +580,31 @@ This one's zip code is 92064.`;
|
|
|
573
580
|
});
|
|
574
581
|
it('not inequality', async () => {
|
|
575
582
|
await createTestEntities();
|
|
576
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
583
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', gte: ['number', 60] });
|
|
577
584
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
578
585
|
});
|
|
579
586
|
it('wrong inequality', async () => {
|
|
580
587
|
await createTestEntities();
|
|
581
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
588
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', lte: ['number', 29.99] });
|
|
582
589
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
583
590
|
});
|
|
584
591
|
it('greater than cdate', async () => {
|
|
585
592
|
await createTestEntities();
|
|
586
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
593
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] });
|
|
587
594
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
588
595
|
});
|
|
589
596
|
it('wrong cdate', async () => {
|
|
590
597
|
await createTestEntities();
|
|
591
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
598
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] });
|
|
592
599
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
593
600
|
});
|
|
594
601
|
it('time selector', async () => {
|
|
595
602
|
await createTestEntities();
|
|
596
|
-
const referenceEntity = await
|
|
597
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
603
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
604
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['timestamp', null, '-1 day'] });
|
|
598
605
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
599
606
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
600
|
-
resultEntity = await nymph.getEntities({ class:
|
|
607
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
601
608
|
type: '|',
|
|
602
609
|
gt: [
|
|
603
610
|
['timestamp', null, '-1 day'],
|
|
@@ -606,54 +613,56 @@ This one's zip code is 92064.`;
|
|
|
606
613
|
});
|
|
607
614
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
608
615
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
609
|
-
resultEntity = await nymph.getEntities({ class:
|
|
616
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['timestamp', null, '-3 days'] });
|
|
610
617
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
611
618
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
612
|
-
resultEntity = await nymph.getEntities({ class:
|
|
619
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['cdate', null, '-1 day'] });
|
|
613
620
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
614
621
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
615
622
|
});
|
|
616
623
|
it('wrong time selector', async () => {
|
|
617
624
|
await createTestEntities();
|
|
618
|
-
const referenceEntity = await
|
|
619
|
-
let resultEntity = await nymph.getEntities({ class:
|
|
625
|
+
const referenceEntity = await TestModel.factory(refGuid);
|
|
626
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] });
|
|
620
627
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
621
628
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
622
|
-
resultEntity = await nymph.getEntities({ class:
|
|
629
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] });
|
|
623
630
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
624
631
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
625
|
-
resultEntity = await nymph.getEntities({ class:
|
|
632
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] });
|
|
626
633
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
627
634
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
628
635
|
});
|
|
629
636
|
it('references', async () => {
|
|
630
637
|
await createTestEntities();
|
|
638
|
+
await testEntity.reference?.$wake();
|
|
631
639
|
expect(testEntity.reference?.test).toEqual('good');
|
|
640
|
+
await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
|
|
632
641
|
expect(testEntity.refArray?.[0].test).toEqual('good');
|
|
633
642
|
});
|
|
634
643
|
it('ref', async () => {
|
|
635
644
|
await createTestEntities();
|
|
636
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
645
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', refGuid] });
|
|
637
646
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
638
647
|
});
|
|
639
648
|
it('not ref', async () => {
|
|
640
649
|
await createTestEntities();
|
|
641
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
650
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', ref: ['reference', (0, guid_1.guid)()] });
|
|
642
651
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
643
652
|
});
|
|
644
653
|
it('wrong ref', async () => {
|
|
645
654
|
await createTestEntities();
|
|
646
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
655
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', (0, guid_1.guid)()] });
|
|
647
656
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
648
657
|
});
|
|
649
658
|
it('nonexistent ref', async () => {
|
|
650
659
|
await createTestEntities();
|
|
651
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
660
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['pickle', refGuid] });
|
|
652
661
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
653
662
|
});
|
|
654
663
|
it('inclusive ref', async () => {
|
|
655
664
|
await createTestEntities();
|
|
656
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
665
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
657
666
|
type: '|',
|
|
658
667
|
ref: [
|
|
659
668
|
['reference', refGuid],
|
|
@@ -664,7 +673,7 @@ This one's zip code is 92064.`;
|
|
|
664
673
|
});
|
|
665
674
|
it('wrong inclusive ref', async () => {
|
|
666
675
|
await createTestEntities();
|
|
667
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
676
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
668
677
|
type: '|',
|
|
669
678
|
ref: [
|
|
670
679
|
['reference', (0, guid_1.guid)()],
|
|
@@ -675,12 +684,12 @@ This one's zip code is 92064.`;
|
|
|
675
684
|
});
|
|
676
685
|
it('ref in an array', async () => {
|
|
677
686
|
await createTestEntities();
|
|
678
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
687
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['refArray', refGuid] });
|
|
679
688
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
680
689
|
});
|
|
681
690
|
it('wrong ref in an array', async () => {
|
|
682
691
|
await createTestEntities();
|
|
683
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
692
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
684
693
|
type: '&',
|
|
685
694
|
ref: [
|
|
686
695
|
['refArray', refGuid],
|
|
@@ -691,7 +700,7 @@ This one's zip code is 92064.`;
|
|
|
691
700
|
});
|
|
692
701
|
it('logic operations', async () => {
|
|
693
702
|
await createTestEntities();
|
|
694
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
703
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
695
704
|
type: '&',
|
|
696
705
|
'!ref': [
|
|
697
706
|
['refArray', (0, guid_1.guid)()],
|
|
@@ -727,34 +736,34 @@ This one's zip code is 92064.`;
|
|
|
727
736
|
});
|
|
728
737
|
it('count return', async () => {
|
|
729
738
|
await createTestEntities();
|
|
730
|
-
const result = await nymph.getEntities({ class:
|
|
739
|
+
const result = await nymph.getEntities({ class: TestModel });
|
|
731
740
|
const resultCount = await nymph.getEntities({
|
|
732
|
-
class:
|
|
741
|
+
class: TestModel,
|
|
733
742
|
return: 'count',
|
|
734
743
|
});
|
|
735
744
|
expect(resultCount).toBeGreaterThanOrEqual(1);
|
|
736
745
|
expect(resultCount).toEqual(result.length);
|
|
737
|
-
const resultSelectors = await nymph.getEntities({ class:
|
|
738
|
-
const resultSelectorsCount = await nymph.getEntities({ class:
|
|
746
|
+
const resultSelectors = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', refGuid] });
|
|
747
|
+
const resultSelectorsCount = await nymph.getEntities({ class: TestModel, return: 'count' }, { type: '&', ref: ['reference', refGuid] });
|
|
739
748
|
expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
|
|
740
749
|
expect(resultSelectorsCount).toEqual(resultSelectors.length);
|
|
741
750
|
const resultSelectorsLimit = await nymph.getEntities({
|
|
742
|
-
class:
|
|
751
|
+
class: TestModel,
|
|
743
752
|
limit: 1,
|
|
744
753
|
return: 'count',
|
|
745
754
|
});
|
|
746
755
|
expect(resultSelectorsLimit).toEqual(1);
|
|
747
756
|
const resultSelectorsSingle = await nymph.getEntity({
|
|
748
|
-
class:
|
|
757
|
+
class: TestModel,
|
|
749
758
|
return: 'count',
|
|
750
759
|
});
|
|
751
760
|
expect(resultSelectorsSingle).toEqual(1);
|
|
752
|
-
const resultSelectorsEmpty = await nymph.getEntities({ class:
|
|
761
|
+
const resultSelectorsEmpty = await nymph.getEntities({ class: TestModel, return: 'count' }, { type: '&', ref: ['reference', (0, guid_1.guid)()] });
|
|
753
762
|
expect(resultSelectorsEmpty).toEqual(0);
|
|
754
763
|
});
|
|
755
764
|
it('guid return', async () => {
|
|
756
765
|
await createTestEntities();
|
|
757
|
-
const resultGuid = await nymph.getEntities({ class:
|
|
766
|
+
const resultGuid = await nymph.getEntities({ class: TestModel, return: 'guid' }, {
|
|
758
767
|
type: '&',
|
|
759
768
|
'!ref': [
|
|
760
769
|
['refArray', (0, guid_1.guid)()],
|
|
@@ -790,7 +799,7 @@ This one's zip code is 92064.`;
|
|
|
790
799
|
});
|
|
791
800
|
it('deep selector', async () => {
|
|
792
801
|
await createTestEntities();
|
|
793
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
802
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
794
803
|
type: '&',
|
|
795
804
|
'!ref': [
|
|
796
805
|
['refArray', (0, guid_1.guid)()],
|
|
@@ -830,7 +839,7 @@ This one's zip code is 92064.`;
|
|
|
830
839
|
],
|
|
831
840
|
});
|
|
832
841
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
833
|
-
const resultEntity2 = await nymph.getEntities({ class:
|
|
842
|
+
const resultEntity2 = await nymph.getEntities({ class: TestModel }, {
|
|
834
843
|
type: '&',
|
|
835
844
|
'!ref': [
|
|
836
845
|
['refArray', (0, guid_1.guid)()],
|
|
@@ -870,7 +879,7 @@ This one's zip code is 92064.`;
|
|
|
870
879
|
],
|
|
871
880
|
});
|
|
872
881
|
expect(testEntity.$inArray(resultEntity2)).toEqual(true);
|
|
873
|
-
const resultEntity3 = await nymph.getEntities({ class:
|
|
882
|
+
const resultEntity3 = await nymph.getEntities({ class: TestModel }, {
|
|
874
883
|
type: '|',
|
|
875
884
|
selector: [
|
|
876
885
|
{
|
|
@@ -882,7 +891,7 @@ This one's zip code is 92064.`;
|
|
|
882
891
|
],
|
|
883
892
|
});
|
|
884
893
|
expect(testEntity.$inArray(resultEntity3)).toEqual(true);
|
|
885
|
-
const resultEntity4 = await nymph.getEntities({ class:
|
|
894
|
+
const resultEntity4 = await nymph.getEntities({ class: TestModel }, {
|
|
886
895
|
type: '|',
|
|
887
896
|
selector: [
|
|
888
897
|
{
|
|
@@ -902,7 +911,7 @@ This one's zip code is 92064.`;
|
|
|
902
911
|
expect(testEntity.$inArray(resultEntity4)).toEqual(true);
|
|
903
912
|
});
|
|
904
913
|
it('wrong deep selector', async () => {
|
|
905
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
914
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
906
915
|
type: '&',
|
|
907
916
|
selector: [
|
|
908
917
|
{
|
|
@@ -917,62 +926,59 @@ This one's zip code is 92064.`;
|
|
|
917
926
|
});
|
|
918
927
|
it('qref', async () => {
|
|
919
928
|
await createTestEntities();
|
|
920
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
929
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
921
930
|
type: '&',
|
|
922
931
|
qref: [
|
|
923
932
|
'reference',
|
|
924
|
-
[{ class:
|
|
933
|
+
[{ class: TestModel }, { type: '&', equal: ['test', 'good'] }],
|
|
925
934
|
],
|
|
926
935
|
});
|
|
927
936
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
928
937
|
});
|
|
929
938
|
it('not qref', async () => {
|
|
930
939
|
await createTestEntities();
|
|
931
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
940
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
932
941
|
type: '&',
|
|
933
942
|
'!qref': [
|
|
934
943
|
'reference',
|
|
935
|
-
[{ class:
|
|
944
|
+
[{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
|
|
936
945
|
],
|
|
937
946
|
});
|
|
938
947
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
939
948
|
});
|
|
940
949
|
it('wrong qref class', async () => {
|
|
941
950
|
await createTestEntities();
|
|
942
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
951
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
943
952
|
type: '&',
|
|
944
953
|
qref: [
|
|
945
954
|
'reference',
|
|
946
|
-
[{ class:
|
|
955
|
+
[{ class: TestBModel }, { type: '&', equal: ['test', 'good'] }],
|
|
947
956
|
],
|
|
948
957
|
});
|
|
949
958
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
950
959
|
});
|
|
951
960
|
it('wrong qref data', async () => {
|
|
952
961
|
await createTestEntities();
|
|
953
|
-
const resultEntity = await nymph.getEntities({ class:
|
|
962
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
954
963
|
type: '&',
|
|
955
964
|
qref: [
|
|
956
965
|
'reference',
|
|
957
|
-
[{ class:
|
|
966
|
+
[{ class: TestModel }, { type: '&', equal: ['test', 'pickles'] }],
|
|
958
967
|
],
|
|
959
968
|
});
|
|
960
969
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
961
970
|
});
|
|
962
|
-
it('sort option', async () => {
|
|
971
|
+
it('cdate and mdate sort option', async () => {
|
|
963
972
|
await createMultipleTestEntities();
|
|
964
973
|
for (const sort of ['cdate', 'mdate']) {
|
|
965
|
-
let resultEntities = await nymph.getEntities({
|
|
966
|
-
class: testArtifacts_1.TestModel,
|
|
967
|
-
sort: sort,
|
|
968
|
-
});
|
|
974
|
+
let resultEntities = await nymph.getEntities({ class: TestModel, sort });
|
|
969
975
|
expect(resultEntities.length).toBeGreaterThan(100);
|
|
970
976
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
971
977
|
expect(resultEntities[i + 1][sort]).toBeGreaterThan(resultEntities[i][sort] ?? 0);
|
|
972
978
|
}
|
|
973
979
|
let resultGuids = await nymph.getEntities({
|
|
974
|
-
class:
|
|
975
|
-
sort
|
|
980
|
+
class: TestModel,
|
|
981
|
+
sort,
|
|
976
982
|
return: 'guid',
|
|
977
983
|
});
|
|
978
984
|
expect(resultGuids.length).toBeGreaterThan(100);
|
|
@@ -980,43 +986,84 @@ This one's zip code is 92064.`;
|
|
|
980
986
|
expect(resultGuids[i]).toEqual(resultEntities[i].guid);
|
|
981
987
|
}
|
|
982
988
|
resultEntities = await nymph.getEntities({
|
|
983
|
-
class:
|
|
984
|
-
sort
|
|
989
|
+
class: TestModel,
|
|
990
|
+
sort,
|
|
985
991
|
reverse: true,
|
|
986
992
|
});
|
|
987
993
|
expect(resultEntities.length).toBeGreaterThan(100);
|
|
988
994
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
989
995
|
expect(resultEntities[i + 1][sort]).toBeLessThan(resultEntities[i][sort] ?? 0);
|
|
990
996
|
}
|
|
991
|
-
resultEntities = await nymph.getEntities({ class:
|
|
997
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort }, { type: '&', match: ['name', '^Multi Test '] });
|
|
992
998
|
expect(resultEntities.length).toEqual(100);
|
|
993
999
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
994
1000
|
expect(resultEntities[i + 1][sort]).toBeGreaterThan(resultEntities[i][sort] ?? 0);
|
|
995
1001
|
}
|
|
996
|
-
resultEntities = await nymph.getEntities({ class:
|
|
1002
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort, reverse: true }, { type: '&', match: ['name', '^Multi Test '] });
|
|
997
1003
|
expect(resultEntities.length).toEqual(100);
|
|
998
1004
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
999
1005
|
expect(resultEntities[i + 1][sort]).toBeLessThan(resultEntities[i][sort] ?? 0);
|
|
1000
1006
|
}
|
|
1001
1007
|
}
|
|
1002
1008
|
});
|
|
1009
|
+
it('property sort option', async () => {
|
|
1010
|
+
await createMultipleTestEntities();
|
|
1011
|
+
let resultEntities = await nymph.getEntities({
|
|
1012
|
+
class: TestModel,
|
|
1013
|
+
sort: 'number',
|
|
1014
|
+
});
|
|
1015
|
+
expect(resultEntities.length).toBeGreaterThan(100);
|
|
1016
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1017
|
+
expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThanOrEqual(resultEntities[i].number ?? 0);
|
|
1018
|
+
}
|
|
1019
|
+
let resultGuids = await nymph.getEntities({
|
|
1020
|
+
class: TestModel,
|
|
1021
|
+
sort: 'number',
|
|
1022
|
+
return: 'guid',
|
|
1023
|
+
});
|
|
1024
|
+
expect(resultGuids.length).toBeGreaterThan(100);
|
|
1025
|
+
for (let i = 0; i < resultGuids.length - 1; i++) {
|
|
1026
|
+
expect(resultGuids[i]).toEqual(resultEntities[i].guid);
|
|
1027
|
+
}
|
|
1028
|
+
resultEntities = await nymph.getEntities({
|
|
1029
|
+
class: TestModel,
|
|
1030
|
+
sort: 'number',
|
|
1031
|
+
reverse: true,
|
|
1032
|
+
});
|
|
1033
|
+
expect(resultEntities.length).toBeGreaterThan(100);
|
|
1034
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1035
|
+
expect(resultEntities[i + 1].number ?? 0).toBeLessThanOrEqual(resultEntities[i].number ?? Infinity);
|
|
1036
|
+
}
|
|
1037
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort: 'number' }, { type: '&', match: ['name', '^Multi Test '] });
|
|
1038
|
+
expect(resultEntities.length).toEqual(100);
|
|
1039
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1040
|
+
expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThan(resultEntities[i].number ?? 0);
|
|
1041
|
+
expect(resultEntities[i].name).toEqual(`Multi Test ${100 - (resultEntities[i].number ?? 0)}`);
|
|
1042
|
+
}
|
|
1043
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort: 'number', reverse: true }, { type: '&', match: ['name', '^Multi Test '] });
|
|
1044
|
+
expect(resultEntities.length).toEqual(100);
|
|
1045
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1046
|
+
expect(resultEntities[i + 1].number ?? 0).toBeLessThan(resultEntities[i].number ?? Infinity);
|
|
1047
|
+
expect(resultEntities[i].name).toEqual(`Multi Test ${100 - (resultEntities[i].number ?? 0)}`);
|
|
1048
|
+
}
|
|
1049
|
+
});
|
|
1003
1050
|
it('delete reference', async () => {
|
|
1004
1051
|
await createTestEntities();
|
|
1052
|
+
await testEntity.reference?.$wake();
|
|
1005
1053
|
expect(await testEntity.reference?.$delete()).toEqual(true);
|
|
1054
|
+
await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
|
|
1006
1055
|
expect(testEntity.reference?.guid).toBeNull();
|
|
1007
1056
|
});
|
|
1008
1057
|
it('delete', async () => {
|
|
1009
1058
|
await createTestEntities();
|
|
1010
1059
|
expect(await testEntity.$delete()).toEqual(true);
|
|
1011
1060
|
expect(testEntity.guid).toBeNull();
|
|
1012
|
-
const entity = await nymph.getEntity({ class:
|
|
1061
|
+
const entity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid });
|
|
1013
1062
|
expect(entity).toBeNull();
|
|
1014
1063
|
});
|
|
1015
1064
|
}
|
|
1016
1065
|
exports.QueriesTest = QueriesTest;
|
|
1017
1066
|
function UIDTest(nymph, it) {
|
|
1018
|
-
nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
1019
|
-
nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
1020
1067
|
it('delete old test data', async () => {
|
|
1021
1068
|
expect(await nymph.deleteUID('TestUID')).toEqual(true);
|
|
1022
1069
|
expect(await nymph.deleteUID('NewUID')).toEqual(true);
|
|
@@ -1049,22 +1096,22 @@ function UIDTest(nymph, it) {
|
|
|
1049
1096
|
}
|
|
1050
1097
|
exports.UIDTest = UIDTest;
|
|
1051
1098
|
function ExportImportTest(nymph, it) {
|
|
1052
|
-
nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
1053
|
-
nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
1099
|
+
const TestModel = nymph.addEntityClass(testArtifacts_1.TestModel);
|
|
1100
|
+
const TestBModel = nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
1054
1101
|
async function deleteTestData() {
|
|
1055
|
-
let all = await nymph.getEntities({ class:
|
|
1102
|
+
let all = await nymph.getEntities({ class: TestModel });
|
|
1056
1103
|
expect(Array.isArray(all)).toEqual(true);
|
|
1057
1104
|
for (const cur of all) {
|
|
1058
1105
|
expect(await cur.$delete()).toEqual(true);
|
|
1059
1106
|
}
|
|
1060
|
-
all = await nymph.getEntities({ class:
|
|
1107
|
+
all = await nymph.getEntities({ class: TestModel });
|
|
1061
1108
|
expect(all.length).toEqual(0);
|
|
1062
|
-
all = await nymph.getEntities({ class:
|
|
1109
|
+
all = await nymph.getEntities({ class: TestBModel });
|
|
1063
1110
|
expect(Array.isArray(all)).toEqual(true);
|
|
1064
1111
|
for (const cur of all) {
|
|
1065
1112
|
expect(await cur.$delete()).toEqual(true);
|
|
1066
1113
|
}
|
|
1067
|
-
all = await nymph.getEntities({ class:
|
|
1114
|
+
all = await nymph.getEntities({ class: TestBModel });
|
|
1068
1115
|
expect(all.length).toEqual(0);
|
|
1069
1116
|
expect(await nymph.deleteUID('TestUID')).toEqual(true);
|
|
1070
1117
|
expect(await nymph.deleteUID('TestUID2')).toEqual(true);
|
|
@@ -1072,8 +1119,8 @@ function ExportImportTest(nymph, it) {
|
|
|
1072
1119
|
async function checkEntityDataAndCount() {
|
|
1073
1120
|
expect(await nymph.getUID('TestUID')).toEqual(2);
|
|
1074
1121
|
expect(await nymph.getUID('TestUID2')).toEqual(1);
|
|
1075
|
-
const models = await nymph.getEntities({ class:
|
|
1076
|
-
const bmodels = await nymph.getEntities({ class:
|
|
1122
|
+
const models = await nymph.getEntities({ class: TestModel });
|
|
1123
|
+
const bmodels = await nymph.getEntities({ class: TestBModel });
|
|
1077
1124
|
expect(models.length).toEqual(30);
|
|
1078
1125
|
expect(bmodels.length).toEqual(10);
|
|
1079
1126
|
const all = [...models, ...bmodels];
|
|
@@ -1084,9 +1131,11 @@ function ExportImportTest(nymph, it) {
|
|
|
1084
1131
|
expect(model.array).toEqual(['full', 'of', 'values', 500]);
|
|
1085
1132
|
expect(model.number).toEqual(30);
|
|
1086
1133
|
expect(model.timestamp).toBeGreaterThanOrEqual((0, strtotime_1.default)('-2 minutes'));
|
|
1134
|
+
await model.reference?.$wake();
|
|
1087
1135
|
expect(model.reference?.guid).not.toBeNull();
|
|
1088
1136
|
expect(model.reference?.string).toEqual('another');
|
|
1089
1137
|
expect(model.reference?.index?.match(/^\d+b$/)).toBeTruthy();
|
|
1138
|
+
await Promise.all(model.refArray?.map((e) => e.$wake()) || []);
|
|
1090
1139
|
expect(model.refArray?.[0].guid).not.toBeNull();
|
|
1091
1140
|
expect(model.refArray?.[0].guid).toEqual(model.reference?.guid);
|
|
1092
1141
|
}
|
|
@@ -1100,7 +1149,7 @@ function ExportImportTest(nymph, it) {
|
|
|
1100
1149
|
expect(await nymph.newUID('TestUID')).toEqual(2);
|
|
1101
1150
|
expect(await nymph.newUID('TestUID2')).toEqual(1);
|
|
1102
1151
|
for (let i = 0; i < 20; i++) {
|
|
1103
|
-
const EntityClass = i < 15 ?
|
|
1152
|
+
const EntityClass = i < 15 ? TestModel : TestBModel;
|
|
1104
1153
|
const testEntity = await EntityClass.factory();
|
|
1105
1154
|
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1106
1155
|
testEntity.null = null;
|
|
@@ -1128,8 +1177,8 @@ function ExportImportTest(nymph, it) {
|
|
|
1128
1177
|
it('import data', async () => {
|
|
1129
1178
|
expect(await nymph.getUID('TestUID')).toBeNull();
|
|
1130
1179
|
expect(await nymph.getUID('TestUID2')).toBeNull();
|
|
1131
|
-
const models = await nymph.getEntities({ class:
|
|
1132
|
-
const bmodels = await nymph.getEntities({ class:
|
|
1180
|
+
const models = await nymph.getEntities({ class: TestModel });
|
|
1181
|
+
const bmodels = await nymph.getEntities({ class: TestBModel });
|
|
1133
1182
|
expect(models.length).toEqual(0);
|
|
1134
1183
|
expect(bmodels.length).toEqual(0);
|
|
1135
1184
|
expect(await nymph.import(__dirname + '/testentityexport.nex')).toEqual(true);
|