@nymphjs/nymph 1.0.0-beta.11 → 1.0.0-beta.111
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 +540 -0
- package/README.md +23 -21
- package/dist/Entity.d.ts +293 -10
- package/dist/Entity.js +560 -148
- package/dist/Entity.js.map +1 -1
- package/dist/Entity.test.js +52 -13
- package/dist/Entity.test.js.map +1 -1
- package/dist/Entity.types.d.ts +256 -23
- package/dist/Entity.types.js +1 -2
- package/dist/Nymph.d.ts +586 -12
- package/dist/Nymph.js +844 -179
- package/dist/Nymph.js.map +1 -1
- package/dist/Nymph.types.d.ts +81 -8
- package/dist/Nymph.types.js +3 -5
- package/dist/Nymph.types.js.map +1 -1
- package/dist/conf/d.d.ts +43 -0
- package/dist/conf/d.js +1 -2
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/defaults.js +26 -3
- package/dist/conf/defaults.js.map +1 -1
- package/dist/conf/index.d.ts +2 -2
- package/dist/conf/index.js +2 -8
- package/dist/conf/index.js.map +1 -1
- package/dist/driver/NymphDriver.d.ts +201 -40
- package/dist/driver/NymphDriver.js +685 -239
- package/dist/driver/NymphDriver.js.map +1 -1
- package/dist/driver/index.d.ts +2 -2
- package/dist/driver/index.js +3 -23
- package/dist/driver/index.js.map +1 -1
- package/dist/driver/testArtifacts.d.ts +2 -2
- package/dist/driver/testArtifacts.js +909 -93
- package/dist/driver/testArtifacts.js.map +1 -1
- package/dist/errors/ClassNotAvailableError.js +1 -5
- package/dist/errors/ClassNotAvailableError.js.map +1 -1
- package/dist/errors/EntityConflictError.js +1 -5
- package/dist/errors/EntityConflictError.js.map +1 -1
- package/dist/errors/EntityInvalidDataError.d.ts +6 -0
- package/dist/errors/EntityInvalidDataError.js +8 -6
- package/dist/errors/EntityInvalidDataError.js.map +1 -1
- package/dist/errors/EntityIsSleepingReferenceError.js +1 -5
- package/dist/errors/EntityIsSleepingReferenceError.js.map +1 -1
- package/dist/errors/EntityUniqueConstraintError.d.ts +3 -0
- package/dist/errors/EntityUniqueConstraintError.js +7 -0
- package/dist/errors/EntityUniqueConstraintError.js.map +1 -0
- package/dist/errors/HttpError.d.ts +5 -0
- package/dist/errors/HttpError.js +11 -0
- package/dist/errors/HttpError.js.map +1 -0
- package/dist/errors/InvalidParametersError.js +1 -5
- package/dist/errors/InvalidParametersError.js.map +1 -1
- package/dist/errors/InvalidStateError.d.ts +3 -0
- package/dist/errors/InvalidStateError.js +7 -0
- package/dist/errors/InvalidStateError.js.map +1 -0
- package/dist/errors/NotConfiguredError.js +1 -5
- package/dist/errors/NotConfiguredError.js.map +1 -1
- package/dist/errors/QueryFailedError.d.ts +2 -1
- package/dist/errors/QueryFailedError.js +5 -6
- package/dist/errors/QueryFailedError.js.map +1 -1
- package/dist/errors/UnableToConnectError.js +1 -5
- package/dist/errors/UnableToConnectError.js.map +1 -1
- package/dist/errors/index.d.ts +11 -8
- package/dist/errors/index.js +11 -24
- package/dist/errors/index.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +14 -34
- package/dist/index.js.map +1 -1
- package/dist/nymphJoiProps.d.ts +1 -1
- package/dist/nymphJoiProps.js +10 -15
- package/dist/nymphJoiProps.js.map +1 -1
- package/dist/testArtifacts.d.ts +19 -6
- package/dist/testArtifacts.js +32 -37
- package/dist/testArtifacts.js.map +1 -1
- package/dist/testMocks.d.ts +27 -12
- package/dist/testMocks.js +40 -29
- package/dist/testMocks.js.map +1 -1
- package/dist/utils.d.ts +4 -4
- package/dist/utils.js +40 -29
- package/dist/utils.js.map +1 -1
- package/jest.config.js +11 -2
- package/package.json +24 -20
- package/src/Entity.test.ts +50 -7
- package/src/Entity.ts +489 -150
- package/src/Entity.types.ts +72 -74
- package/src/Nymph.ts +985 -322
- package/src/Nymph.types.ts +150 -27
- package/src/conf/d.ts +25 -0
- package/src/conf/defaults.ts +34 -1
- package/src/conf/index.ts +2 -2
- package/src/driver/NymphDriver.ts +859 -412
- package/src/driver/index.ts +2 -2
- package/src/driver/testArtifacts.ts +1090 -186
- package/src/errors/EntityUniqueConstraintError.ts +6 -0
- package/src/errors/HttpError.ts +12 -0
- package/src/errors/InvalidStateError.ts +6 -0
- package/src/errors/QueryFailedError.ts +3 -1
- package/src/errors/index.ts +14 -8
- package/src/index.ts +11 -11
- package/src/nymphJoiProps.ts +2 -2
- package/src/testArtifacts.ts +20 -20
- package/src/testMocks.ts +76 -35
- package/src/type/locutus.d.ts +3 -0
- package/src/utils.ts +39 -18
- package/tsconfig.json +5 -3
- package/typedoc.json +4 -0
|
@@ -1,34 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const TestBModel = nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
1
|
+
import { dirname } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import strtotime from 'locutus/php/datetime/strtotime.js';
|
|
5
|
+
import { guid } from '@nymphjs/guid';
|
|
6
|
+
import { EntityUniqueConstraintError } from '../errors/index.js';
|
|
7
|
+
import { TestBModel as TestBModelClass, TestModel as TestModelClass, TestEmptyModel as TestEmptyModelClass, } from '../testArtifacts.js';
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
export function EntitiesTest(nymph, it) {
|
|
10
|
+
const TestModel = nymph.addEntityClass(TestModelClass);
|
|
11
|
+
const TestBModel = nymph.addEntityClass(TestBModelClass);
|
|
12
|
+
const TestEmptyModel = nymph.addEntityClass(TestEmptyModelClass);
|
|
14
13
|
let testEntity;
|
|
15
14
|
let testGuid;
|
|
16
15
|
let refGuid;
|
|
17
16
|
let createdMultiple = false;
|
|
17
|
+
// The entities created by this function are required by many of the tests.
|
|
18
18
|
async function createTestEntities() {
|
|
19
19
|
if (testGuid != null) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
+
// Creating entity...
|
|
22
23
|
testEntity = await TestModel.factory();
|
|
24
|
+
// Saving entity...
|
|
23
25
|
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
24
26
|
testEntity.null = null;
|
|
25
27
|
testEntity.string = 'test';
|
|
26
|
-
testEntity.array = [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
testEntity.array = [
|
|
29
|
+
'full',
|
|
30
|
+
'of',
|
|
31
|
+
'values',
|
|
32
|
+
500,
|
|
33
|
+
{ test: true },
|
|
34
|
+
{ nullbyte: '\\\x00\u0000 \x00' },
|
|
35
|
+
];
|
|
36
|
+
testEntity.match = matchValue;
|
|
37
|
+
testEntity.search = searchValue;
|
|
32
38
|
testEntity.number = 30;
|
|
33
39
|
testEntity.numberString = '30';
|
|
34
40
|
testEntity.timestamp = Date.now();
|
|
@@ -37,7 +43,7 @@ This one's zip code is 92064.`;
|
|
|
37
43
|
testGuid = testEntity.guid;
|
|
38
44
|
const entityReferenceTest = new TestModel();
|
|
39
45
|
entityReferenceTest.string = 'wrong';
|
|
40
|
-
entityReferenceTest.timestamp = (
|
|
46
|
+
entityReferenceTest.timestamp = strtotime('-2 days') * 1000;
|
|
41
47
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
42
48
|
refGuid = entityReferenceTest.guid;
|
|
43
49
|
testEntity.reference = entityReferenceTest;
|
|
@@ -45,38 +51,53 @@ This one's zip code is 92064.`;
|
|
|
45
51
|
expect(await testEntity.$save()).toEqual(true);
|
|
46
52
|
entityReferenceTest.test = 'good';
|
|
47
53
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
48
|
-
|
|
49
|
-
expect(testEntity).toBeInstanceOf(TestModel);
|
|
50
|
-
expect(testEntity.guid).toEqual(testGuid);
|
|
54
|
+
// Test asynchronous getEntity.
|
|
51
55
|
testEntity = (await nymph.getEntity({ class: TestModel }, testGuid));
|
|
52
56
|
expect(testEntity).toBeInstanceOf(TestModel);
|
|
53
57
|
expect(testEntity.guid).toEqual(testGuid);
|
|
54
58
|
}
|
|
59
|
+
// The entities created by this function are required by many of the tests.
|
|
55
60
|
async function createMultipleTestEntities() {
|
|
56
61
|
if (!createdMultiple) {
|
|
57
62
|
createdMultiple = true;
|
|
63
|
+
// Creating 100 entities...
|
|
58
64
|
for (let i = 0; i < 100; i++) {
|
|
59
65
|
const testEntity = await TestModel.factory();
|
|
60
66
|
testEntity.name = `Multi Test ${i}`;
|
|
67
|
+
// Reverse the number for sort testing.
|
|
68
|
+
testEntity.number = 100 - i;
|
|
61
69
|
testEntity.$removeTag('test');
|
|
62
70
|
testEntity.$addTag('multiTest');
|
|
63
71
|
expect(await testEntity.$save()).toEqual(true);
|
|
72
|
+
// Pause for a few milliseconds so the cdate and mdate can be sorted.
|
|
64
73
|
await new Promise((res) => setTimeout(() => res(1), 5));
|
|
65
74
|
}
|
|
66
75
|
}
|
|
67
76
|
}
|
|
68
77
|
it('delete old test data', async () => {
|
|
69
|
-
let
|
|
70
|
-
expect(Array.isArray(
|
|
71
|
-
for (const cur of
|
|
78
|
+
let amodels = await nymph.getEntities({ class: TestModel });
|
|
79
|
+
expect(Array.isArray(amodels)).toEqual(true);
|
|
80
|
+
for (const cur of amodels) {
|
|
72
81
|
expect(await cur.$delete()).toEqual(true);
|
|
73
82
|
}
|
|
74
|
-
|
|
75
|
-
expect(
|
|
83
|
+
amodels = await nymph.getEntities({ class: TestModel });
|
|
84
|
+
expect(amodels.length).toEqual(0);
|
|
85
|
+
let bmodels = await nymph.getEntities({ class: TestBModel });
|
|
86
|
+
expect(Array.isArray(bmodels)).toEqual(true);
|
|
87
|
+
for (const cur of bmodels) {
|
|
88
|
+
expect(await cur.$delete()).toEqual(true);
|
|
89
|
+
}
|
|
90
|
+
bmodels = await nymph.getEntities({ class: TestBModel });
|
|
91
|
+
expect(bmodels.length).toEqual(0);
|
|
76
92
|
});
|
|
77
93
|
it('create entity', async () => {
|
|
78
94
|
await createTestEntities();
|
|
79
95
|
});
|
|
96
|
+
it("doesn't create empty entity", async () => {
|
|
97
|
+
const testEntity = await TestEmptyModel.factory();
|
|
98
|
+
expect(await testEntity.$save()).toBeFalsy();
|
|
99
|
+
expect(testEntity.guid).toBeNull();
|
|
100
|
+
});
|
|
80
101
|
it('update mdate on save', async () => {
|
|
81
102
|
await createTestEntities();
|
|
82
103
|
const oldMdate = testEntity.mdate ?? Infinity;
|
|
@@ -89,15 +110,123 @@ This one's zip code is 92064.`;
|
|
|
89
110
|
});
|
|
90
111
|
it('by guid', async () => {
|
|
91
112
|
await createTestEntities();
|
|
113
|
+
// Retrieving entity by GUID...
|
|
92
114
|
let resultEntity = await nymph.getEntity({ class: TestModel }, testGuid);
|
|
93
115
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
116
|
+
// Using class constructor...
|
|
94
117
|
resultEntity = await TestModel.factory(testGuid);
|
|
95
118
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
96
|
-
|
|
119
|
+
// Testing wrong GUID...
|
|
120
|
+
resultEntity = await nymph.getEntity({ class: TestModel }, guid());
|
|
97
121
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
98
122
|
});
|
|
123
|
+
it('guaranteed guid', async () => {
|
|
124
|
+
// Creating entity...
|
|
125
|
+
const testEntity = await TestModel.factory();
|
|
126
|
+
// Saving entity...
|
|
127
|
+
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
128
|
+
testEntity.null = null;
|
|
129
|
+
testEntity.string = 'test';
|
|
130
|
+
testEntity.array = [];
|
|
131
|
+
testEntity.match = matchValue;
|
|
132
|
+
testEntity.number = 30;
|
|
133
|
+
testEntity.numberString = '30';
|
|
134
|
+
testEntity.timestamp = Date.now();
|
|
135
|
+
// Get the guaranteed GUID.
|
|
136
|
+
const testGuid = testEntity.$getGuaranteedGUID();
|
|
137
|
+
expect(await testEntity.$save()).toEqual(true);
|
|
138
|
+
expect(testEntity.guid).not.toBeNull();
|
|
139
|
+
expect(testEntity.guid).toEqual(testGuid);
|
|
140
|
+
// Retrieving entity by GUID...
|
|
141
|
+
let resultEntity = await nymph.getEntity({ class: TestModel }, testGuid);
|
|
142
|
+
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
143
|
+
// Delete the entity.
|
|
144
|
+
expect(await testEntity.$delete()).toEqual(true);
|
|
145
|
+
});
|
|
146
|
+
it('create, list, and delete indexes', async () => {
|
|
147
|
+
// Delete existing indexes.
|
|
148
|
+
const existingIndexes = await nymph.getIndexes(TestModel.ETYPE);
|
|
149
|
+
for (let index of existingIndexes) {
|
|
150
|
+
await nymph.deleteIndex(TestModel.ETYPE, index.scope, index.name);
|
|
151
|
+
}
|
|
152
|
+
const existingBIndexes = await nymph.getIndexes(TestBModel.ETYPE);
|
|
153
|
+
for (let index of existingBIndexes) {
|
|
154
|
+
await nymph.deleteIndex(TestBModel.ETYPE, index.scope, index.name);
|
|
155
|
+
}
|
|
156
|
+
const sortByName = (arr) => {
|
|
157
|
+
arr.sort((a, b) => a.name.localeCompare(b.name));
|
|
158
|
+
return arr;
|
|
159
|
+
};
|
|
160
|
+
expect(await nymph.addIndex(TestModel.ETYPE, {
|
|
161
|
+
scope: 'data',
|
|
162
|
+
name: 'testindex',
|
|
163
|
+
property: 'test',
|
|
164
|
+
})).toEqual(true);
|
|
165
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
166
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
167
|
+
]);
|
|
168
|
+
expect(await nymph.addIndex(TestModel.ETYPE, {
|
|
169
|
+
scope: 'data',
|
|
170
|
+
name: 'secondone',
|
|
171
|
+
property: 'match',
|
|
172
|
+
})).toEqual(true);
|
|
173
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
174
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
175
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
176
|
+
]);
|
|
177
|
+
expect(await nymph.addIndex(TestModel.ETYPE, {
|
|
178
|
+
scope: 'references',
|
|
179
|
+
name: 'refone',
|
|
180
|
+
property: 'reference',
|
|
181
|
+
})).toEqual(true);
|
|
182
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
183
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
184
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
185
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
186
|
+
]);
|
|
187
|
+
expect(await nymph.addIndex(TestModel.ETYPE, {
|
|
188
|
+
scope: 'tokens',
|
|
189
|
+
name: 'tokenone',
|
|
190
|
+
property: 'search',
|
|
191
|
+
})).toEqual(true);
|
|
192
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
193
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
194
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
195
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
196
|
+
{ scope: 'tokens', name: 'tokenone', property: 'search' },
|
|
197
|
+
]);
|
|
198
|
+
expect(await nymph.addIndex(TestBModel.ETYPE, {
|
|
199
|
+
scope: 'data',
|
|
200
|
+
name: 'flooflab',
|
|
201
|
+
property: 'string',
|
|
202
|
+
})).toEqual(true);
|
|
203
|
+
expect(sortByName(await nymph.getIndexes(TestBModel.ETYPE))).toEqual([
|
|
204
|
+
{ scope: 'data', name: 'flooflab', property: 'string' },
|
|
205
|
+
]);
|
|
206
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
207
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
208
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
209
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
210
|
+
{ scope: 'tokens', name: 'tokenone', property: 'search' },
|
|
211
|
+
]);
|
|
212
|
+
expect(await nymph.deleteIndex(TestBModel.ETYPE, 'data', 'flooflab')).toEqual(true);
|
|
213
|
+
expect(await nymph.getIndexes(TestBModel.ETYPE)).toEqual([]);
|
|
214
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
215
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
216
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
217
|
+
{ scope: 'data', name: 'testindex', property: 'test' },
|
|
218
|
+
{ scope: 'tokens', name: 'tokenone', property: 'search' },
|
|
219
|
+
]);
|
|
220
|
+
expect(await nymph.deleteIndex(TestModel.ETYPE, 'data', 'testindex')).toEqual(true);
|
|
221
|
+
expect(sortByName(await nymph.getIndexes(TestModel.ETYPE))).toEqual([
|
|
222
|
+
{ scope: 'references', name: 'refone', property: 'reference' },
|
|
223
|
+
{ scope: 'data', name: 'secondone', property: 'match' },
|
|
224
|
+
{ scope: 'tokens', name: 'tokenone', property: 'search' },
|
|
225
|
+
]);
|
|
226
|
+
});
|
|
99
227
|
it('transactions', async () => {
|
|
100
228
|
await createTestEntities();
|
|
229
|
+
// Verify not in a transaction.
|
|
101
230
|
expect(await nymph.inTransaction()).toEqual(false);
|
|
102
231
|
let transaction = await nymph.startTransaction('test');
|
|
103
232
|
testEntity.$nymph = transaction;
|
|
@@ -106,38 +235,57 @@ This one's zip code is 92064.`;
|
|
|
106
235
|
await transaction.rollback('test');
|
|
107
236
|
return;
|
|
108
237
|
}
|
|
238
|
+
// Change a value in the test entity.
|
|
109
239
|
testEntity.string = 'bad value';
|
|
110
240
|
expect(await testEntity.$save()).toEqual(true);
|
|
241
|
+
// Rollback the transaction.
|
|
111
242
|
await transaction.rollback('test');
|
|
243
|
+
// Verify not in a transaction.
|
|
112
244
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
245
|
+
// Verify the value is correct.
|
|
113
246
|
await testEntity.$refresh();
|
|
114
247
|
expect(testEntity.string).toEqual('test');
|
|
248
|
+
// Start a new transaction.
|
|
115
249
|
transaction = await nymph.startTransaction('test');
|
|
116
250
|
testEntity.$nymph = transaction;
|
|
251
|
+
// Verify in a transaction.
|
|
117
252
|
expect(await transaction.inTransaction()).toEqual(true);
|
|
253
|
+
// Delete the entity.
|
|
118
254
|
expect(await testEntity.$delete()).toEqual(true);
|
|
119
255
|
const resultEntity = await transaction.getEntity({ class: TestModel }, testGuid);
|
|
120
256
|
expect(resultEntity).toBeNull();
|
|
257
|
+
// Rollback the transaction.
|
|
121
258
|
await transaction.rollback('test');
|
|
259
|
+
// Verify not in a transaction.
|
|
122
260
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
261
|
+
// Verify it's back.
|
|
123
262
|
testEntity = (await transaction.getEntity({ class: TestModel }, testGuid));
|
|
124
263
|
expect(testEntity.guid).toEqual(testGuid);
|
|
125
|
-
transaction
|
|
264
|
+
// Start a new transaction with a dot in the name.
|
|
265
|
+
transaction = await nymph.startTransaction('test.1');
|
|
126
266
|
testEntity.$nymph = transaction;
|
|
267
|
+
// Verify in a transaction.
|
|
127
268
|
expect(await transaction.inTransaction()).toEqual(true);
|
|
269
|
+
// Make a change.
|
|
128
270
|
testEntity.string = 'fish';
|
|
129
271
|
expect(await testEntity.$save()).toEqual(true);
|
|
130
|
-
|
|
272
|
+
// Commit the transaction.
|
|
273
|
+
await transaction.commit('test.1');
|
|
131
274
|
testEntity.$nymph = nymph;
|
|
275
|
+
// Verify not in a transaction.
|
|
132
276
|
expect(await transaction.inTransaction()).toEqual(false);
|
|
277
|
+
// Verify the value is correct.
|
|
133
278
|
await testEntity.$refresh();
|
|
134
279
|
expect(testEntity.string).toEqual('fish');
|
|
280
|
+
// Finally, change it back.
|
|
135
281
|
testEntity.string = 'test';
|
|
136
282
|
expect(await testEntity.$save()).toEqual(true);
|
|
283
|
+
// TODO: nested transactions
|
|
137
284
|
});
|
|
138
285
|
it('options', async () => {
|
|
139
286
|
await createTestEntities();
|
|
140
|
-
|
|
287
|
+
// Testing entity order, offset, limit...
|
|
288
|
+
let resultEntities = await nymph.getEntities({
|
|
141
289
|
class: TestModel,
|
|
142
290
|
reverse: true,
|
|
143
291
|
offset: 1,
|
|
@@ -146,102 +294,159 @@ This one's zip code is 92064.`;
|
|
|
146
294
|
}, { type: '&', tag: 'test' });
|
|
147
295
|
expect(resultEntities.length).toEqual(1);
|
|
148
296
|
expect(testEntity.$is(resultEntities[0])).toEqual(true);
|
|
297
|
+
// Testing null sort...
|
|
298
|
+
resultEntities = await nymph.getEntities({
|
|
299
|
+
class: TestModel,
|
|
300
|
+
reverse: true,
|
|
301
|
+
sort: null,
|
|
302
|
+
}, { type: '&', tag: 'test' });
|
|
303
|
+
expect(testEntity.$inArray(resultEntities)).toEqual(true);
|
|
149
304
|
});
|
|
150
305
|
it('guid and tags', async () => {
|
|
151
306
|
await createTestEntities();
|
|
307
|
+
// Retrieving entity by GUID and tags...
|
|
152
308
|
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid, tag: 'test' });
|
|
153
309
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
154
310
|
});
|
|
155
311
|
it('or selector', async () => {
|
|
156
312
|
await createTestEntities();
|
|
157
|
-
|
|
313
|
+
// Retrieving entity by GUID and tags...
|
|
314
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '|', guid: [testGuid, guid()] });
|
|
158
315
|
expect(testEntity.$is(resultEntity)).toEqual(true);
|
|
159
316
|
});
|
|
160
317
|
it('wrong or selector', async () => {
|
|
161
318
|
await createTestEntities();
|
|
162
|
-
|
|
319
|
+
// Retrieving entity by GUID and tags...
|
|
320
|
+
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '|', guid: [guid(), guid()] });
|
|
163
321
|
expect(testEntity.$is(resultEntity)).toEqual(false);
|
|
164
322
|
});
|
|
165
323
|
it('not guid', async () => {
|
|
166
324
|
await createTestEntities();
|
|
167
|
-
|
|
325
|
+
// Retrieving entity by !GUID...
|
|
326
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', '!guid': guid(), tag: 'test' });
|
|
168
327
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
169
328
|
});
|
|
170
329
|
it('not tags', async () => {
|
|
171
330
|
await createTestEntities();
|
|
331
|
+
// Retrieving entity by !tags...
|
|
172
332
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', guid: testGuid, '!tag': ['barbecue', 'pickles'] });
|
|
173
333
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
174
334
|
});
|
|
175
335
|
it('guid and wrong tags', async () => {
|
|
176
336
|
await createTestEntities();
|
|
337
|
+
// Testing GUID and wrong tags...
|
|
177
338
|
const resultEntity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid, tag: ['pickles'] });
|
|
178
339
|
expect(resultEntity).toBeNull();
|
|
179
340
|
});
|
|
180
341
|
it('tags', async () => {
|
|
181
342
|
await createTestEntities();
|
|
343
|
+
// Retrieving entity by tags...
|
|
182
344
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' });
|
|
183
345
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
184
346
|
});
|
|
185
347
|
it('wrong tags', async () => {
|
|
186
348
|
await createTestEntities();
|
|
349
|
+
// Testing wrong tags...
|
|
187
350
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles' });
|
|
188
351
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
189
352
|
});
|
|
190
353
|
it('inclusive tags', async () => {
|
|
191
354
|
await createTestEntities();
|
|
355
|
+
// Retrieving entity by tags inclusively...
|
|
192
356
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '|', tag: ['pickles', 'test', 'barbecue'] });
|
|
193
357
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
194
358
|
});
|
|
195
359
|
it('wrong inclusive tags', async () => {
|
|
196
360
|
await createTestEntities();
|
|
361
|
+
// Testing wrong inclusive tags...
|
|
197
362
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '|', tag: ['pickles', 'barbecue'] });
|
|
198
363
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
199
364
|
});
|
|
200
365
|
it('mixed tags', async () => {
|
|
201
366
|
await createTestEntities();
|
|
367
|
+
// Retrieving entity by mixed tags...
|
|
202
368
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', tag: ['pickles', 'test', 'barbecue'] });
|
|
203
369
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
204
370
|
});
|
|
205
371
|
it('wrong inclusive mixed tags', async () => {
|
|
206
372
|
await createTestEntities();
|
|
373
|
+
// Testing wrong inclusive mixed tags...
|
|
207
374
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', tag: ['pickles', 'barbecue'] });
|
|
208
375
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
209
376
|
});
|
|
210
377
|
it('wrong exclusive mixed tags', async () => {
|
|
211
378
|
await createTestEntities();
|
|
379
|
+
// Testing wrong exclusive mixed tags...
|
|
212
380
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles' }, { type: '|', tag: ['test', 'barbecue'] });
|
|
213
381
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
214
382
|
});
|
|
215
383
|
it('defined', async () => {
|
|
216
384
|
await createTestEntities();
|
|
385
|
+
// Retrieving entity by defined...
|
|
217
386
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', defined: 'string' });
|
|
218
387
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
219
388
|
});
|
|
220
389
|
it('not defined', async () => {
|
|
221
390
|
await createTestEntities();
|
|
391
|
+
// Retrieving entity by !defined...
|
|
222
392
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!defined': 'pickles' });
|
|
223
393
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
224
394
|
});
|
|
225
395
|
it('defined in a not and clause', async () => {
|
|
226
396
|
await createTestEntities();
|
|
397
|
+
// Retrieving entity by defined in not and clause...
|
|
227
398
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '!&', defined: 'pickles' }, { type: '&', tag: 'test' });
|
|
228
399
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
229
400
|
});
|
|
230
401
|
it('equal', async () => {
|
|
231
402
|
await createTestEntities();
|
|
232
|
-
|
|
403
|
+
// Retrieving entity by equal...
|
|
404
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', equal: ['string', 'test'] });
|
|
405
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
406
|
+
// Retrieving entity by equal...
|
|
407
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', equal: ['null', null] });
|
|
408
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
409
|
+
// Retrieving entity by equal...
|
|
410
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', equal: ['boolean', true] });
|
|
411
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
412
|
+
// Retrieving entity by equal...
|
|
413
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', equal: ['number', 30] });
|
|
414
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
415
|
+
// Retrieving entity by equal...
|
|
416
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
417
|
+
type: '&',
|
|
418
|
+
equal: [
|
|
419
|
+
'array',
|
|
420
|
+
[
|
|
421
|
+
'full',
|
|
422
|
+
'of',
|
|
423
|
+
'values',
|
|
424
|
+
500,
|
|
425
|
+
{ test: true },
|
|
426
|
+
{ nullbyte: '\\\x00\u0000 \x00' },
|
|
427
|
+
],
|
|
428
|
+
],
|
|
429
|
+
});
|
|
430
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
431
|
+
// Retrieving entity by equal...
|
|
432
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
433
|
+
type: '&',
|
|
434
|
+
equal: ['match', matchValue],
|
|
435
|
+
});
|
|
233
436
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
234
437
|
});
|
|
235
438
|
it('not equal', async () => {
|
|
236
439
|
await createTestEntities();
|
|
237
440
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
238
441
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
442
|
+
// Retrieving entity by !equal...
|
|
239
443
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!equal': ['string', 'wrong'] });
|
|
240
444
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
241
445
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
242
446
|
});
|
|
243
447
|
it('like', async () => {
|
|
244
448
|
await createTestEntities();
|
|
449
|
+
// Retrieving entity by like...
|
|
245
450
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', like: ['string', 't_s%'] });
|
|
246
451
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
247
452
|
});
|
|
@@ -249,12 +454,14 @@ This one's zip code is 92064.`;
|
|
|
249
454
|
await createTestEntities();
|
|
250
455
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
251
456
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
457
|
+
// Retrieving entity by !like...
|
|
252
458
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!like': ['string', 'wr_n%'] });
|
|
253
459
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
254
460
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
255
461
|
});
|
|
256
462
|
it('ilike', async () => {
|
|
257
463
|
await createTestEntities();
|
|
464
|
+
// Retrieving entity by ilike...
|
|
258
465
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ilike: ['string', 'T_s%'] });
|
|
259
466
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
260
467
|
});
|
|
@@ -262,56 +469,71 @@ This one's zip code is 92064.`;
|
|
|
262
469
|
await createTestEntities();
|
|
263
470
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
264
471
|
expect(referenceEntity.guid).toEqual(refGuid);
|
|
472
|
+
// Retrieving entity by !ilike...
|
|
265
473
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', '!ilike': ['string', 'wr_n%'] });
|
|
266
474
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
267
475
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
268
476
|
});
|
|
269
477
|
it('like with wrong case', async () => {
|
|
270
478
|
await createTestEntities();
|
|
479
|
+
// Retrieving entity by like...
|
|
271
480
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', like: ['string', 'T_s%'] });
|
|
272
481
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
273
482
|
});
|
|
274
483
|
it('tags and equal', async () => {
|
|
275
484
|
await createTestEntities();
|
|
485
|
+
// Retrieving entity by tags and equal...
|
|
276
486
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', equal: ['string', 'test'] });
|
|
277
487
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
278
488
|
});
|
|
279
489
|
it('wrong tags right equal', async () => {
|
|
280
490
|
await createTestEntities();
|
|
491
|
+
// Testing wrong tags and right equal...
|
|
281
492
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles', equal: ['string', 'test'] });
|
|
282
493
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
283
494
|
});
|
|
284
495
|
it('right tags wrong equal', async () => {
|
|
285
496
|
await createTestEntities();
|
|
497
|
+
// Testing right tags and wrong equal...
|
|
286
498
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', equal: ['string', 'pickles'] });
|
|
287
499
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
288
500
|
});
|
|
289
501
|
it('wrong tags wrong equal', async () => {
|
|
290
502
|
await createTestEntities();
|
|
503
|
+
// Testing wrong tags and wrong equal...
|
|
291
504
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickles', equal: ['string', 'pickles'] });
|
|
292
505
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
293
506
|
});
|
|
294
507
|
it('contain', async () => {
|
|
295
508
|
await createTestEntities();
|
|
509
|
+
// Retrieving entity by contain...
|
|
296
510
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 'values'] });
|
|
297
511
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
298
|
-
|
|
512
|
+
// Retrieving entity by contain...
|
|
513
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 500] });
|
|
514
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
515
|
+
// Retrieving entity by contain...
|
|
516
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', { test: true }] });
|
|
299
517
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
300
518
|
});
|
|
301
519
|
it('not contain', async () => {
|
|
302
520
|
await createTestEntities();
|
|
521
|
+
// Retrieving entity by !contain...
|
|
303
522
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', contain: ['array', 'pickles'] });
|
|
304
523
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
305
524
|
});
|
|
306
525
|
it('wrong contain', async () => {
|
|
307
526
|
await createTestEntities();
|
|
527
|
+
// Testing wrong contain...
|
|
308
528
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['array', 'pickles'] });
|
|
309
529
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
530
|
+
// Testing wrong contain...
|
|
310
531
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', contain: ['string', 'pickles'] });
|
|
311
532
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
312
533
|
});
|
|
313
534
|
it('match', async () => {
|
|
314
535
|
await createTestEntities();
|
|
536
|
+
// Retrieving entity by regex match...
|
|
315
537
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', match: ['match', '.*'] });
|
|
316
538
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
317
539
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', match: ['match', 'Edward McCheese'] });
|
|
@@ -339,12 +561,14 @@ This one's zip code is 92064.`;
|
|
|
339
561
|
});
|
|
340
562
|
it('imatch', async () => {
|
|
341
563
|
await createTestEntities();
|
|
564
|
+
// Retrieving entity by regex match...
|
|
342
565
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', imatch: ['match', 'edward mccheese'] });
|
|
343
566
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
344
567
|
});
|
|
345
568
|
it('wrong match', async () => {
|
|
346
569
|
await createTestEntities();
|
|
347
|
-
|
|
570
|
+
// Testing wrong regex match...
|
|
571
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', match: ['match', '='] });
|
|
348
572
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
349
573
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickle', match: ['match', '.*'] });
|
|
350
574
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
@@ -359,16 +583,139 @@ This one's zip code is 92064.`;
|
|
|
359
583
|
});
|
|
360
584
|
it('match wrong case', async () => {
|
|
361
585
|
await createTestEntities();
|
|
586
|
+
// Retrieving entity by regex match...
|
|
362
587
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', match: ['match', 'edward mccheese'] });
|
|
363
588
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
364
589
|
});
|
|
365
590
|
it('match and equal inclusive', async () => {
|
|
366
591
|
await createTestEntities();
|
|
592
|
+
// Retrieving entity by regex + equal inclusively...
|
|
367
593
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', equal: ['string', 'pickles'], match: ['string', 'test'] });
|
|
368
594
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
369
595
|
});
|
|
596
|
+
it('basic search', async () => {
|
|
597
|
+
await createTestEntities();
|
|
598
|
+
// Retrieving entity by full text search...
|
|
599
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
600
|
+
type: '&',
|
|
601
|
+
tag: 'test',
|
|
602
|
+
search: [
|
|
603
|
+
'search',
|
|
604
|
+
'Declaration of the thirteen united States of America',
|
|
605
|
+
],
|
|
606
|
+
});
|
|
607
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
608
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, {
|
|
609
|
+
type: '|',
|
|
610
|
+
search: [
|
|
611
|
+
['string', 'pickle'],
|
|
612
|
+
['search', 'Declaration of the thirteen united States of America'],
|
|
613
|
+
],
|
|
614
|
+
});
|
|
615
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
616
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
617
|
+
type: '&',
|
|
618
|
+
tag: 'test',
|
|
619
|
+
search: ['search', 'July 4, 1776'],
|
|
620
|
+
});
|
|
621
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
622
|
+
});
|
|
623
|
+
it('or search', async () => {
|
|
624
|
+
await createTestEntities();
|
|
625
|
+
// Retrieving entity by full text search...
|
|
626
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
627
|
+
type: '&',
|
|
628
|
+
tag: 'test',
|
|
629
|
+
search: ['search', 'Declaration or pickles'],
|
|
630
|
+
});
|
|
631
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
632
|
+
});
|
|
633
|
+
it('series search', async () => {
|
|
634
|
+
await createTestEntities();
|
|
635
|
+
// Retrieving entity by full text search...
|
|
636
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
637
|
+
type: '&',
|
|
638
|
+
tag: 'test',
|
|
639
|
+
search: ['search', '"excited domestic insurrections"'],
|
|
640
|
+
});
|
|
641
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
642
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
643
|
+
type: '&',
|
|
644
|
+
tag: 'test',
|
|
645
|
+
search: ['search', "'exciting domestic insurrected'"],
|
|
646
|
+
});
|
|
647
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
648
|
+
});
|
|
649
|
+
it('negated search', async () => {
|
|
650
|
+
await createTestEntities();
|
|
651
|
+
// Retrieving entity by full text search...
|
|
652
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
653
|
+
type: '&',
|
|
654
|
+
tag: 'test',
|
|
655
|
+
search: ['search', '-pickle'],
|
|
656
|
+
});
|
|
657
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
658
|
+
});
|
|
659
|
+
it('combined search', async () => {
|
|
660
|
+
await createTestEntities();
|
|
661
|
+
// Retrieving entity by full text search...
|
|
662
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
663
|
+
type: '&',
|
|
664
|
+
tag: 'test',
|
|
665
|
+
search: ['search', 'Declaration -pickle'],
|
|
666
|
+
});
|
|
667
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
668
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
669
|
+
type: '&',
|
|
670
|
+
tag: 'test',
|
|
671
|
+
search: ['search', 'Declaration "General Congress"'],
|
|
672
|
+
});
|
|
673
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
674
|
+
});
|
|
675
|
+
it('wrong search', async () => {
|
|
676
|
+
await createTestEntities();
|
|
677
|
+
// Testing wrong search...
|
|
678
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', search: ['search', 'pickles'] });
|
|
679
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
680
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'pickle', search: ['search', 'Declaration'] });
|
|
681
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
682
|
+
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
683
|
+
type: '|',
|
|
684
|
+
search: [
|
|
685
|
+
['string', 'pickle'],
|
|
686
|
+
['search', 'Hawaii'],
|
|
687
|
+
],
|
|
688
|
+
});
|
|
689
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
690
|
+
});
|
|
691
|
+
it('search with only stop words', async () => {
|
|
692
|
+
await createTestEntities();
|
|
693
|
+
// Testing wrong search...
|
|
694
|
+
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', search: ['search', 'i am'] });
|
|
695
|
+
expect(resultEntity).toEqual([]);
|
|
696
|
+
});
|
|
697
|
+
it('search must be case insensitive', async () => {
|
|
698
|
+
await createTestEntities();
|
|
699
|
+
// Retrieving entity by full text search...
|
|
700
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
701
|
+
type: '&',
|
|
702
|
+
tag: 'test',
|
|
703
|
+
search: [
|
|
704
|
+
'search',
|
|
705
|
+
'DECLARATION OF THE THIRTEEN UNITED STATES OF AMERICA',
|
|
706
|
+
],
|
|
707
|
+
});
|
|
708
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
709
|
+
});
|
|
710
|
+
it('search and equal inclusive', async () => {
|
|
711
|
+
await createTestEntities();
|
|
712
|
+
// Retrieving entity by fts + equal inclusively...
|
|
713
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '|', equal: ['string', 'pickles'], search: ['string', 'test'] });
|
|
714
|
+
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
715
|
+
});
|
|
370
716
|
it('greater than', async () => {
|
|
371
717
|
await createTestEntities();
|
|
718
|
+
// Retrieving entity by inequality...
|
|
372
719
|
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
373
720
|
type: '|',
|
|
374
721
|
gt: [
|
|
@@ -377,6 +724,7 @@ This one's zip code is 92064.`;
|
|
|
377
724
|
],
|
|
378
725
|
});
|
|
379
726
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
727
|
+
// Retrieving entity by inequality...
|
|
380
728
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
381
729
|
type: '|',
|
|
382
730
|
gt: [
|
|
@@ -385,6 +733,7 @@ This one's zip code is 92064.`;
|
|
|
385
733
|
],
|
|
386
734
|
});
|
|
387
735
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
736
|
+
// Retrieving entity by inequality...
|
|
388
737
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
389
738
|
type: '|',
|
|
390
739
|
gt: [
|
|
@@ -393,6 +742,7 @@ This one's zip code is 92064.`;
|
|
|
393
742
|
],
|
|
394
743
|
});
|
|
395
744
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
745
|
+
// Retrieving entity by inequality...
|
|
396
746
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
397
747
|
type: '|',
|
|
398
748
|
gt: [
|
|
@@ -401,6 +751,7 @@ This one's zip code is 92064.`;
|
|
|
401
751
|
],
|
|
402
752
|
});
|
|
403
753
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
754
|
+
// Retrieving entity by inequality...
|
|
404
755
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
405
756
|
type: '|',
|
|
406
757
|
gt: [
|
|
@@ -409,6 +760,7 @@ This one's zip code is 92064.`;
|
|
|
409
760
|
],
|
|
410
761
|
});
|
|
411
762
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
763
|
+
// Retrieving entity by inequality...
|
|
412
764
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
413
765
|
type: '|',
|
|
414
766
|
gt: [
|
|
@@ -420,6 +772,7 @@ This one's zip code is 92064.`;
|
|
|
420
772
|
});
|
|
421
773
|
it('greater than or equal', async () => {
|
|
422
774
|
await createTestEntities();
|
|
775
|
+
// Retrieving entity by inequality...
|
|
423
776
|
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
424
777
|
type: '|',
|
|
425
778
|
gte: [
|
|
@@ -428,6 +781,7 @@ This one's zip code is 92064.`;
|
|
|
428
781
|
],
|
|
429
782
|
});
|
|
430
783
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
784
|
+
// Retrieving entity by inequality...
|
|
431
785
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
432
786
|
type: '|',
|
|
433
787
|
gte: [
|
|
@@ -436,6 +790,7 @@ This one's zip code is 92064.`;
|
|
|
436
790
|
],
|
|
437
791
|
});
|
|
438
792
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
793
|
+
// Retrieving entity by inequality...
|
|
439
794
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
440
795
|
type: '|',
|
|
441
796
|
gte: [
|
|
@@ -444,6 +799,7 @@ This one's zip code is 92064.`;
|
|
|
444
799
|
],
|
|
445
800
|
});
|
|
446
801
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
802
|
+
// Retrieving entity by inequality...
|
|
447
803
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
448
804
|
type: '|',
|
|
449
805
|
gte: [
|
|
@@ -452,6 +808,7 @@ This one's zip code is 92064.`;
|
|
|
452
808
|
],
|
|
453
809
|
});
|
|
454
810
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
811
|
+
// Retrieving entity by inequality...
|
|
455
812
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
456
813
|
type: '|',
|
|
457
814
|
gte: [
|
|
@@ -460,6 +817,7 @@ This one's zip code is 92064.`;
|
|
|
460
817
|
],
|
|
461
818
|
});
|
|
462
819
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
820
|
+
// Retrieving entity by inequality...
|
|
463
821
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
464
822
|
type: '|',
|
|
465
823
|
gte: [
|
|
@@ -471,6 +829,7 @@ This one's zip code is 92064.`;
|
|
|
471
829
|
});
|
|
472
830
|
it('less than', async () => {
|
|
473
831
|
await createTestEntities();
|
|
832
|
+
// Retrieving entity by inequality...
|
|
474
833
|
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
475
834
|
type: '|',
|
|
476
835
|
lt: [
|
|
@@ -479,6 +838,7 @@ This one's zip code is 92064.`;
|
|
|
479
838
|
],
|
|
480
839
|
});
|
|
481
840
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
841
|
+
// Retrieving entity by inequality...
|
|
482
842
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
483
843
|
type: '|',
|
|
484
844
|
lt: [
|
|
@@ -487,6 +847,7 @@ This one's zip code is 92064.`;
|
|
|
487
847
|
],
|
|
488
848
|
});
|
|
489
849
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
850
|
+
// Retrieving entity by inequality...
|
|
490
851
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
491
852
|
type: '|',
|
|
492
853
|
lt: [
|
|
@@ -495,6 +856,7 @@ This one's zip code is 92064.`;
|
|
|
495
856
|
],
|
|
496
857
|
});
|
|
497
858
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
859
|
+
// Retrieving entity by inequality...
|
|
498
860
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
499
861
|
type: '|',
|
|
500
862
|
lt: [
|
|
@@ -503,6 +865,7 @@ This one's zip code is 92064.`;
|
|
|
503
865
|
],
|
|
504
866
|
});
|
|
505
867
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
868
|
+
// Retrieving entity by inequality...
|
|
506
869
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
507
870
|
type: '|',
|
|
508
871
|
lt: [
|
|
@@ -511,6 +874,7 @@ This one's zip code is 92064.`;
|
|
|
511
874
|
],
|
|
512
875
|
});
|
|
513
876
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
877
|
+
// Retrieving entity by inequality...
|
|
514
878
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
515
879
|
type: '|',
|
|
516
880
|
lt: [
|
|
@@ -522,6 +886,7 @@ This one's zip code is 92064.`;
|
|
|
522
886
|
});
|
|
523
887
|
it('less than or equal', async () => {
|
|
524
888
|
await createTestEntities();
|
|
889
|
+
// Retrieving entity by inequality...
|
|
525
890
|
let resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
526
891
|
type: '|',
|
|
527
892
|
lte: [
|
|
@@ -530,6 +895,7 @@ This one's zip code is 92064.`;
|
|
|
530
895
|
],
|
|
531
896
|
});
|
|
532
897
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
898
|
+
// Retrieving entity by inequality...
|
|
533
899
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
534
900
|
type: '|',
|
|
535
901
|
lte: [
|
|
@@ -538,6 +904,7 @@ This one's zip code is 92064.`;
|
|
|
538
904
|
],
|
|
539
905
|
});
|
|
540
906
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
907
|
+
// Retrieving entity by inequality...
|
|
541
908
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
542
909
|
type: '|',
|
|
543
910
|
lte: [
|
|
@@ -546,6 +913,7 @@ This one's zip code is 92064.`;
|
|
|
546
913
|
],
|
|
547
914
|
});
|
|
548
915
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
916
|
+
// Retrieving entity by inequality...
|
|
549
917
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
550
918
|
type: '|',
|
|
551
919
|
lte: [
|
|
@@ -554,6 +922,7 @@ This one's zip code is 92064.`;
|
|
|
554
922
|
],
|
|
555
923
|
});
|
|
556
924
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
925
|
+
// Retrieving entity by inequality...
|
|
557
926
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
558
927
|
type: '|',
|
|
559
928
|
lte: [
|
|
@@ -562,6 +931,7 @@ This one's zip code is 92064.`;
|
|
|
562
931
|
],
|
|
563
932
|
});
|
|
564
933
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
934
|
+
// Retrieving entity by inequality...
|
|
565
935
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
566
936
|
type: '|',
|
|
567
937
|
lte: [
|
|
@@ -573,30 +943,36 @@ This one's zip code is 92064.`;
|
|
|
573
943
|
});
|
|
574
944
|
it('not inequality', async () => {
|
|
575
945
|
await createTestEntities();
|
|
946
|
+
// Retrieving entity by !inequality...
|
|
576
947
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', gte: ['number', 60] });
|
|
577
948
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
578
949
|
});
|
|
579
950
|
it('wrong inequality', async () => {
|
|
580
951
|
await createTestEntities();
|
|
952
|
+
// Testing wrong inequality...
|
|
581
953
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', lte: ['number', 29.99] });
|
|
582
954
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
583
955
|
});
|
|
584
956
|
it('greater than cdate', async () => {
|
|
585
957
|
await createTestEntities();
|
|
958
|
+
// Retrieving entity by time...
|
|
586
959
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['cdate', (testEntity.cdate ?? 0) - 120] });
|
|
587
960
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
588
961
|
});
|
|
589
962
|
it('wrong cdate', async () => {
|
|
590
963
|
await createTestEntities();
|
|
964
|
+
// Testing wrong time...
|
|
591
965
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gte: ['cdate', (testEntity.cdate ?? 0) + 1] });
|
|
592
966
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
593
967
|
});
|
|
594
968
|
it('time selector', async () => {
|
|
595
969
|
await createTestEntities();
|
|
596
970
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
971
|
+
// Retrieving entity by relative time...
|
|
597
972
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['timestamp', null, '-1 day'] });
|
|
598
973
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
599
974
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
975
|
+
// Retrieving entity by relative time inclusively...
|
|
600
976
|
resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
601
977
|
type: '|',
|
|
602
978
|
gt: [
|
|
@@ -606,9 +982,11 @@ This one's zip code is 92064.`;
|
|
|
606
982
|
});
|
|
607
983
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
608
984
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
985
|
+
// Retrieving entity by relative time...
|
|
609
986
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['timestamp', null, '-3 days'] });
|
|
610
987
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
611
988
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
989
|
+
// Retrieving entity by relative time...
|
|
612
990
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', gt: ['cdate', null, '-1 day'] });
|
|
613
991
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
614
992
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(true);
|
|
@@ -616,86 +994,102 @@ This one's zip code is 92064.`;
|
|
|
616
994
|
it('wrong time selector', async () => {
|
|
617
995
|
await createTestEntities();
|
|
618
996
|
const referenceEntity = await TestModel.factory(refGuid);
|
|
997
|
+
// Retrieving entity by relative time...
|
|
619
998
|
let resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['timestamp', null, '+1 day'] });
|
|
620
999
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
621
1000
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
1001
|
+
// Retrieving entity by relative time...
|
|
622
1002
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', lt: ['timestamp', null, '-3 days'] });
|
|
623
1003
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
624
1004
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
1005
|
+
// Retrieving entity by relative time...
|
|
625
1006
|
resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test', gt: ['cdate', null, '+1 day'] });
|
|
626
1007
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
627
1008
|
expect(referenceEntity.$inArray(resultEntity)).toEqual(false);
|
|
628
1009
|
});
|
|
629
1010
|
it('references', async () => {
|
|
630
1011
|
await createTestEntities();
|
|
1012
|
+
// Testing referenced entities...
|
|
1013
|
+
await testEntity.reference?.$wake();
|
|
631
1014
|
expect(testEntity.reference?.test).toEqual('good');
|
|
1015
|
+
// Testing referenced entity arrays...
|
|
1016
|
+
await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
|
|
632
1017
|
expect(testEntity.refArray?.[0].test).toEqual('good');
|
|
633
1018
|
});
|
|
634
1019
|
it('ref', async () => {
|
|
635
1020
|
await createTestEntities();
|
|
1021
|
+
// Retrieving entity by reference...
|
|
636
1022
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', refGuid] });
|
|
637
1023
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
638
1024
|
});
|
|
639
1025
|
it('not ref', async () => {
|
|
640
1026
|
await createTestEntities();
|
|
641
|
-
|
|
1027
|
+
// Retrieving entity by !reference...
|
|
1028
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', tag: 'test' }, { type: '!&', ref: ['reference', guid()] });
|
|
642
1029
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
643
1030
|
});
|
|
644
1031
|
it('wrong ref', async () => {
|
|
645
1032
|
await createTestEntities();
|
|
646
|
-
|
|
1033
|
+
// Testing wrong reference...
|
|
1034
|
+
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', guid()] });
|
|
647
1035
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
648
1036
|
});
|
|
649
1037
|
it('nonexistent ref', async () => {
|
|
650
1038
|
await createTestEntities();
|
|
1039
|
+
// Testing non-existent reference...
|
|
651
1040
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['pickle', refGuid] });
|
|
652
1041
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
653
1042
|
});
|
|
654
1043
|
it('inclusive ref', async () => {
|
|
655
1044
|
await createTestEntities();
|
|
1045
|
+
// Retrieving entity by inclusive reference...
|
|
656
1046
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
657
1047
|
type: '|',
|
|
658
1048
|
ref: [
|
|
659
1049
|
['reference', refGuid],
|
|
660
|
-
['reference',
|
|
1050
|
+
['reference', guid()],
|
|
661
1051
|
],
|
|
662
1052
|
});
|
|
663
1053
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
664
1054
|
});
|
|
665
1055
|
it('wrong inclusive ref', async () => {
|
|
666
1056
|
await createTestEntities();
|
|
1057
|
+
// Testing wrong inclusive reference...
|
|
667
1058
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
668
1059
|
type: '|',
|
|
669
1060
|
ref: [
|
|
670
|
-
['reference',
|
|
671
|
-
['reference',
|
|
1061
|
+
['reference', guid()],
|
|
1062
|
+
['reference', guid()],
|
|
672
1063
|
],
|
|
673
1064
|
});
|
|
674
1065
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
675
1066
|
});
|
|
676
1067
|
it('ref in an array', async () => {
|
|
677
1068
|
await createTestEntities();
|
|
1069
|
+
// Retrieving entity by array reference...
|
|
678
1070
|
const resultEntity = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['refArray', refGuid] });
|
|
679
1071
|
expect(testEntity.$inArray(resultEntity)).toEqual(true);
|
|
680
1072
|
});
|
|
681
1073
|
it('wrong ref in an array', async () => {
|
|
682
1074
|
await createTestEntities();
|
|
1075
|
+
// Testing wrong array reference...
|
|
683
1076
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
684
1077
|
type: '&',
|
|
685
1078
|
ref: [
|
|
686
1079
|
['refArray', refGuid],
|
|
687
|
-
['refArray',
|
|
1080
|
+
['refArray', guid()],
|
|
688
1081
|
],
|
|
689
1082
|
});
|
|
690
1083
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
691
1084
|
});
|
|
692
1085
|
it('logic operations', async () => {
|
|
693
1086
|
await createTestEntities();
|
|
1087
|
+
// Testing logic operations...
|
|
694
1088
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
695
1089
|
type: '&',
|
|
696
1090
|
'!ref': [
|
|
697
|
-
['refArray',
|
|
698
|
-
['refArray',
|
|
1091
|
+
['refArray', guid()],
|
|
1092
|
+
['refArray', guid()],
|
|
699
1093
|
],
|
|
700
1094
|
'!lte': ['number', 29.99],
|
|
701
1095
|
}, {
|
|
@@ -712,6 +1106,8 @@ This one's zip code is 92064.`;
|
|
|
712
1106
|
['array', 'of'],
|
|
713
1107
|
['array', 'values'],
|
|
714
1108
|
['array', 500],
|
|
1109
|
+
['array', { test: true }],
|
|
1110
|
+
['array', { nullbyte: '\\\x00\u0000 \x00' }],
|
|
715
1111
|
],
|
|
716
1112
|
}, {
|
|
717
1113
|
type: '!|',
|
|
@@ -728,6 +1124,7 @@ This one's zip code is 92064.`;
|
|
|
728
1124
|
it('count return', async () => {
|
|
729
1125
|
await createTestEntities();
|
|
730
1126
|
const result = await nymph.getEntities({ class: TestModel });
|
|
1127
|
+
// Testing count return...
|
|
731
1128
|
const resultCount = await nymph.getEntities({
|
|
732
1129
|
class: TestModel,
|
|
733
1130
|
return: 'count',
|
|
@@ -735,30 +1132,35 @@ This one's zip code is 92064.`;
|
|
|
735
1132
|
expect(resultCount).toBeGreaterThanOrEqual(1);
|
|
736
1133
|
expect(resultCount).toEqual(result.length);
|
|
737
1134
|
const resultSelectors = await nymph.getEntities({ class: TestModel }, { type: '&', ref: ['reference', refGuid] });
|
|
1135
|
+
// Testing count return with selectors...
|
|
738
1136
|
const resultSelectorsCount = await nymph.getEntities({ class: TestModel, return: 'count' }, { type: '&', ref: ['reference', refGuid] });
|
|
739
1137
|
expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
|
|
740
1138
|
expect(resultSelectorsCount).toEqual(resultSelectors.length);
|
|
1139
|
+
// Testing count return with limit...
|
|
741
1140
|
const resultSelectorsLimit = await nymph.getEntities({
|
|
742
1141
|
class: TestModel,
|
|
743
1142
|
limit: 1,
|
|
744
1143
|
return: 'count',
|
|
745
1144
|
});
|
|
746
1145
|
expect(resultSelectorsLimit).toEqual(1);
|
|
1146
|
+
// Testing count return with limit...
|
|
747
1147
|
const resultSelectorsSingle = await nymph.getEntity({
|
|
748
1148
|
class: TestModel,
|
|
749
1149
|
return: 'count',
|
|
750
1150
|
});
|
|
751
1151
|
expect(resultSelectorsSingle).toEqual(1);
|
|
752
|
-
|
|
1152
|
+
// Testing empty count...
|
|
1153
|
+
const resultSelectorsEmpty = await nymph.getEntities({ class: TestModel, return: 'count' }, { type: '&', ref: ['reference', guid()] });
|
|
753
1154
|
expect(resultSelectorsEmpty).toEqual(0);
|
|
754
1155
|
});
|
|
755
1156
|
it('guid return', async () => {
|
|
756
1157
|
await createTestEntities();
|
|
1158
|
+
// Testing guid return using logic operations...
|
|
757
1159
|
const resultGuid = await nymph.getEntities({ class: TestModel, return: 'guid' }, {
|
|
758
1160
|
type: '&',
|
|
759
1161
|
'!ref': [
|
|
760
|
-
['refArray',
|
|
761
|
-
['refArray',
|
|
1162
|
+
['refArray', guid()],
|
|
1163
|
+
['refArray', guid()],
|
|
762
1164
|
],
|
|
763
1165
|
'!lte': ['number', 29.99],
|
|
764
1166
|
}, {
|
|
@@ -775,6 +1177,8 @@ This one's zip code is 92064.`;
|
|
|
775
1177
|
['array', 'of'],
|
|
776
1178
|
['array', 'values'],
|
|
777
1179
|
['array', 500],
|
|
1180
|
+
['array', { test: true }],
|
|
1181
|
+
['array', { nullbyte: '\\\x00\u0000 \x00' }],
|
|
778
1182
|
],
|
|
779
1183
|
}, {
|
|
780
1184
|
type: '!|',
|
|
@@ -788,13 +1192,57 @@ This one's zip code is 92064.`;
|
|
|
788
1192
|
});
|
|
789
1193
|
expect(resultGuid.indexOf(testEntity.guid ?? '')).toBeGreaterThan(-1);
|
|
790
1194
|
});
|
|
1195
|
+
it('object return', async () => {
|
|
1196
|
+
await createTestEntities();
|
|
1197
|
+
// Testing object return using logic operations...
|
|
1198
|
+
const resultObjects = await nymph.getEntities({ class: TestModel, return: 'object' }, {
|
|
1199
|
+
type: '&',
|
|
1200
|
+
'!ref': [
|
|
1201
|
+
['refArray', guid()],
|
|
1202
|
+
['refArray', guid()],
|
|
1203
|
+
],
|
|
1204
|
+
'!lte': ['number', 29.99],
|
|
1205
|
+
}, {
|
|
1206
|
+
type: '|',
|
|
1207
|
+
'!lte': [
|
|
1208
|
+
['number', 29.99],
|
|
1209
|
+
['number', 30],
|
|
1210
|
+
],
|
|
1211
|
+
}, {
|
|
1212
|
+
type: '!&',
|
|
1213
|
+
'!equal': ['string', 'test'],
|
|
1214
|
+
'!contain': [
|
|
1215
|
+
['array', 'full'],
|
|
1216
|
+
['array', 'of'],
|
|
1217
|
+
['array', 'values'],
|
|
1218
|
+
['array', 500],
|
|
1219
|
+
['array', { test: true }],
|
|
1220
|
+
['array', { nullbyte: '\\\x00\u0000 \x00' }],
|
|
1221
|
+
],
|
|
1222
|
+
}, {
|
|
1223
|
+
type: '!|',
|
|
1224
|
+
'!equal': ['string', 'test'],
|
|
1225
|
+
contain: [
|
|
1226
|
+
['array', 'full'],
|
|
1227
|
+
['array', 'of'],
|
|
1228
|
+
['array', 'values'],
|
|
1229
|
+
['array', 500],
|
|
1230
|
+
],
|
|
1231
|
+
});
|
|
1232
|
+
const resultObject = resultObjects.find((entity) => entity.guid === testEntity.guid);
|
|
1233
|
+
expect(resultObject).toBeInstanceOf(Object);
|
|
1234
|
+
expect(resultObject).not.toBeInstanceOf(TestModel);
|
|
1235
|
+
expect(Array.isArray(resultObject?.tags)).toBeTruthy();
|
|
1236
|
+
expect(resultObject?.string).toEqual('test');
|
|
1237
|
+
});
|
|
791
1238
|
it('deep selector', async () => {
|
|
792
1239
|
await createTestEntities();
|
|
1240
|
+
// Testing deep selectors...
|
|
793
1241
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
794
1242
|
type: '&',
|
|
795
1243
|
'!ref': [
|
|
796
|
-
['refArray',
|
|
797
|
-
['refArray',
|
|
1244
|
+
['refArray', guid()],
|
|
1245
|
+
['refArray', guid()],
|
|
798
1246
|
],
|
|
799
1247
|
'!lte': ['number', 29.99],
|
|
800
1248
|
}, {
|
|
@@ -815,6 +1263,8 @@ This one's zip code is 92064.`;
|
|
|
815
1263
|
['array', 'of'],
|
|
816
1264
|
['array', 'values'],
|
|
817
1265
|
['array', 500],
|
|
1266
|
+
['array', { test: true }],
|
|
1267
|
+
['array', { nullbyte: '\\\x00\u0000 \x00' }],
|
|
818
1268
|
],
|
|
819
1269
|
},
|
|
820
1270
|
{
|
|
@@ -833,8 +1283,8 @@ This one's zip code is 92064.`;
|
|
|
833
1283
|
const resultEntity2 = await nymph.getEntities({ class: TestModel }, {
|
|
834
1284
|
type: '&',
|
|
835
1285
|
'!ref': [
|
|
836
|
-
['refArray',
|
|
837
|
-
['refArray',
|
|
1286
|
+
['refArray', guid()],
|
|
1287
|
+
['refArray', guid()],
|
|
838
1288
|
],
|
|
839
1289
|
'!lte': ['number', 29.99],
|
|
840
1290
|
}, {
|
|
@@ -855,6 +1305,8 @@ This one's zip code is 92064.`;
|
|
|
855
1305
|
['array', 'of'],
|
|
856
1306
|
['array', 'values'],
|
|
857
1307
|
['array', 500],
|
|
1308
|
+
['array', { test: true }],
|
|
1309
|
+
['array', { nullbyte: '\\\x00\u0000 \x00' }],
|
|
858
1310
|
],
|
|
859
1311
|
},
|
|
860
1312
|
{
|
|
@@ -875,7 +1327,7 @@ This one's zip code is 92064.`;
|
|
|
875
1327
|
selector: [
|
|
876
1328
|
{
|
|
877
1329
|
type: '&',
|
|
878
|
-
'!ref': ['refArray',
|
|
1330
|
+
'!ref': ['refArray', guid()],
|
|
879
1331
|
'!lte': ['number', 29.99],
|
|
880
1332
|
},
|
|
881
1333
|
{ type: '&', gte: ['number', 16000] },
|
|
@@ -887,7 +1339,7 @@ This one's zip code is 92064.`;
|
|
|
887
1339
|
selector: [
|
|
888
1340
|
{
|
|
889
1341
|
type: '&',
|
|
890
|
-
'!ref': ['refArray',
|
|
1342
|
+
'!ref': ['refArray', guid()],
|
|
891
1343
|
'!lte': ['number', 29.99],
|
|
892
1344
|
},
|
|
893
1345
|
{
|
|
@@ -902,12 +1354,13 @@ This one's zip code is 92064.`;
|
|
|
902
1354
|
expect(testEntity.$inArray(resultEntity4)).toEqual(true);
|
|
903
1355
|
});
|
|
904
1356
|
it('wrong deep selector', async () => {
|
|
1357
|
+
// Testing wrong deep selectors...
|
|
905
1358
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
906
1359
|
type: '&',
|
|
907
1360
|
selector: [
|
|
908
1361
|
{
|
|
909
1362
|
type: '&',
|
|
910
|
-
'!ref': ['refArray',
|
|
1363
|
+
'!ref': ['refArray', guid()],
|
|
911
1364
|
'!lte': ['number', 29.99],
|
|
912
1365
|
},
|
|
913
1366
|
{ type: '&', gte: ['number', 16000] },
|
|
@@ -917,6 +1370,7 @@ This one's zip code is 92064.`;
|
|
|
917
1370
|
});
|
|
918
1371
|
it('qref', async () => {
|
|
919
1372
|
await createTestEntities();
|
|
1373
|
+
// Retrieving entity by qref...
|
|
920
1374
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
921
1375
|
type: '&',
|
|
922
1376
|
qref: [
|
|
@@ -928,6 +1382,7 @@ This one's zip code is 92064.`;
|
|
|
928
1382
|
});
|
|
929
1383
|
it('not qref', async () => {
|
|
930
1384
|
await createTestEntities();
|
|
1385
|
+
// Retrieving entity by !qref...
|
|
931
1386
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
932
1387
|
type: '&',
|
|
933
1388
|
'!qref': [
|
|
@@ -939,6 +1394,7 @@ This one's zip code is 92064.`;
|
|
|
939
1394
|
});
|
|
940
1395
|
it('wrong qref class', async () => {
|
|
941
1396
|
await createTestEntities();
|
|
1397
|
+
// Testing wrong qref...
|
|
942
1398
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
943
1399
|
type: '&',
|
|
944
1400
|
qref: [
|
|
@@ -950,6 +1406,7 @@ This one's zip code is 92064.`;
|
|
|
950
1406
|
});
|
|
951
1407
|
it('wrong qref data', async () => {
|
|
952
1408
|
await createTestEntities();
|
|
1409
|
+
// Testing wrong qref...
|
|
953
1410
|
const resultEntity = await nymph.getEntities({ class: TestModel }, {
|
|
954
1411
|
type: '&',
|
|
955
1412
|
qref: [
|
|
@@ -959,62 +1416,188 @@ This one's zip code is 92064.`;
|
|
|
959
1416
|
});
|
|
960
1417
|
expect(testEntity.$inArray(resultEntity)).toEqual(false);
|
|
961
1418
|
});
|
|
962
|
-
it('sort option', async () => {
|
|
1419
|
+
it('cdate and mdate sort option', async () => {
|
|
963
1420
|
await createMultipleTestEntities();
|
|
964
1421
|
for (const sort of ['cdate', 'mdate']) {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
sort: sort,
|
|
968
|
-
});
|
|
1422
|
+
// Retrieving entities sorted...
|
|
1423
|
+
let resultEntities = await nymph.getEntities({ class: TestModel, sort });
|
|
969
1424
|
expect(resultEntities.length).toBeGreaterThan(100);
|
|
970
1425
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
971
1426
|
expect(resultEntities[i + 1][sort]).toBeGreaterThan(resultEntities[i][sort] ?? 0);
|
|
972
1427
|
}
|
|
1428
|
+
// And test the same with guid return...
|
|
973
1429
|
let resultGuids = await nymph.getEntities({
|
|
974
1430
|
class: TestModel,
|
|
975
|
-
sort
|
|
1431
|
+
sort,
|
|
976
1432
|
return: 'guid',
|
|
977
1433
|
});
|
|
978
1434
|
expect(resultGuids.length).toBeGreaterThan(100);
|
|
979
1435
|
for (let i = 0; i < resultGuids.length - 1; i++) {
|
|
980
1436
|
expect(resultGuids[i]).toEqual(resultEntities[i].guid);
|
|
981
1437
|
}
|
|
1438
|
+
// Retrieving entities reverse sorted...
|
|
982
1439
|
resultEntities = await nymph.getEntities({
|
|
983
1440
|
class: TestModel,
|
|
984
|
-
sort
|
|
1441
|
+
sort,
|
|
985
1442
|
reverse: true,
|
|
986
1443
|
});
|
|
987
1444
|
expect(resultEntities.length).toBeGreaterThan(100);
|
|
988
1445
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
989
1446
|
expect(resultEntities[i + 1][sort]).toBeLessThan(resultEntities[i][sort] ?? 0);
|
|
990
1447
|
}
|
|
991
|
-
|
|
1448
|
+
// And again with other selectors.
|
|
1449
|
+
// Retrieving entities sorted...
|
|
1450
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort }, { type: '&', match: ['name', '^Multi Test '] });
|
|
992
1451
|
expect(resultEntities.length).toEqual(100);
|
|
993
1452
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
994
1453
|
expect(resultEntities[i + 1][sort]).toBeGreaterThan(resultEntities[i][sort] ?? 0);
|
|
995
1454
|
}
|
|
996
|
-
|
|
1455
|
+
// Retrieving entities reverse sorted...
|
|
1456
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort, reverse: true }, { type: '&', match: ['name', '^Multi Test '] });
|
|
997
1457
|
expect(resultEntities.length).toEqual(100);
|
|
998
1458
|
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
999
1459
|
expect(resultEntities[i + 1][sort]).toBeLessThan(resultEntities[i][sort] ?? 0);
|
|
1000
1460
|
}
|
|
1001
1461
|
}
|
|
1002
1462
|
});
|
|
1463
|
+
it('property sort option', async () => {
|
|
1464
|
+
await createMultipleTestEntities();
|
|
1465
|
+
// Retrieving entities sorted...
|
|
1466
|
+
let resultEntities = await nymph.getEntities({
|
|
1467
|
+
class: TestModel,
|
|
1468
|
+
sort: 'number',
|
|
1469
|
+
});
|
|
1470
|
+
expect(resultEntities.length).toBeGreaterThan(100);
|
|
1471
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1472
|
+
expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThanOrEqual(resultEntities[i].number ?? 0);
|
|
1473
|
+
}
|
|
1474
|
+
// And test the same with guid return...
|
|
1475
|
+
let resultGuids = await nymph.getEntities({
|
|
1476
|
+
class: TestModel,
|
|
1477
|
+
sort: 'number',
|
|
1478
|
+
return: 'guid',
|
|
1479
|
+
});
|
|
1480
|
+
expect(resultGuids.length).toBeGreaterThan(100);
|
|
1481
|
+
for (let i = 0; i < resultGuids.length - 1; i++) {
|
|
1482
|
+
expect(resultGuids[i]).toEqual(resultEntities[i].guid);
|
|
1483
|
+
}
|
|
1484
|
+
// Retrieving entities reverse sorted...
|
|
1485
|
+
resultEntities = await nymph.getEntities({
|
|
1486
|
+
class: TestModel,
|
|
1487
|
+
sort: 'number',
|
|
1488
|
+
reverse: true,
|
|
1489
|
+
});
|
|
1490
|
+
expect(resultEntities.length).toBeGreaterThan(100);
|
|
1491
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1492
|
+
expect(resultEntities[i + 1].number ?? 0).toBeLessThanOrEqual(resultEntities[i].number ?? Infinity);
|
|
1493
|
+
}
|
|
1494
|
+
// And again with other selectors.
|
|
1495
|
+
// Retrieving entities sorted...
|
|
1496
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort: 'number' }, { type: '&', match: ['name', '^Multi Test '] });
|
|
1497
|
+
expect(resultEntities.length).toEqual(100);
|
|
1498
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1499
|
+
expect(resultEntities[i + 1].number ?? Infinity).toBeGreaterThan(resultEntities[i].number ?? 0);
|
|
1500
|
+
expect(resultEntities[i].name).toEqual(`Multi Test ${100 - (resultEntities[i].number ?? 0)}`);
|
|
1501
|
+
}
|
|
1502
|
+
// Retrieving entities reverse sorted...
|
|
1503
|
+
resultEntities = await nymph.getEntities({ class: TestModel, sort: 'number', reverse: true }, { type: '&', match: ['name', '^Multi Test '] });
|
|
1504
|
+
expect(resultEntities.length).toEqual(100);
|
|
1505
|
+
for (let i = 0; i < resultEntities.length - 1; i++) {
|
|
1506
|
+
expect(resultEntities[i + 1].number ?? 0).toBeLessThan(resultEntities[i].number ?? Infinity);
|
|
1507
|
+
expect(resultEntities[i].name).toEqual(`Multi Test ${100 - (resultEntities[i].number ?? 0)}`);
|
|
1508
|
+
}
|
|
1509
|
+
});
|
|
1003
1510
|
it('delete reference', async () => {
|
|
1004
1511
|
await createTestEntities();
|
|
1512
|
+
// Deleting referenced entities...
|
|
1513
|
+
await testEntity.reference?.$wake();
|
|
1005
1514
|
expect(await testEntity.reference?.$delete()).toEqual(true);
|
|
1515
|
+
await Promise.all(testEntity.refArray?.map((e) => e.$wake()) || []);
|
|
1006
1516
|
expect(testEntity.reference?.guid).toBeNull();
|
|
1007
1517
|
});
|
|
1008
1518
|
it('delete', async () => {
|
|
1009
1519
|
await createTestEntities();
|
|
1520
|
+
// Deleting entity...
|
|
1010
1521
|
expect(await testEntity.$delete()).toEqual(true);
|
|
1011
1522
|
expect(testEntity.guid).toBeNull();
|
|
1012
1523
|
const entity = await nymph.getEntity({ class: TestModel }, { type: '&', guid: testGuid });
|
|
1013
1524
|
expect(entity).toBeNull();
|
|
1014
1525
|
});
|
|
1526
|
+
it('allows non-duplicate unique strings', async () => {
|
|
1527
|
+
// Creating entity...
|
|
1528
|
+
const uniqueEntityA = await TestModel.factory();
|
|
1529
|
+
uniqueEntityA.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1530
|
+
uniqueEntityA.uniques = ['test a'];
|
|
1531
|
+
// Saving entity...
|
|
1532
|
+
expect(await uniqueEntityA.$save()).toEqual(true);
|
|
1533
|
+
expect(uniqueEntityA.guid).not.toBeNull();
|
|
1534
|
+
// Creating entity...
|
|
1535
|
+
const uniqueEntityB = await TestModel.factory();
|
|
1536
|
+
uniqueEntityB.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1537
|
+
uniqueEntityB.uniques = ['test b'];
|
|
1538
|
+
// Saving entity...
|
|
1539
|
+
expect(await uniqueEntityB.$save()).toEqual(true);
|
|
1540
|
+
expect(uniqueEntityB.guid).not.toBeNull();
|
|
1541
|
+
expect(uniqueEntityA.guid).not.toEqual(uniqueEntityB.guid);
|
|
1542
|
+
expect(await uniqueEntityA.$delete()).toEqual(true);
|
|
1543
|
+
expect(await uniqueEntityB.$delete()).toEqual(true);
|
|
1544
|
+
});
|
|
1545
|
+
it('throws on duplicate unique strings', async () => {
|
|
1546
|
+
// Creating entity...
|
|
1547
|
+
const uniqueEntityA = await TestModel.factory();
|
|
1548
|
+
uniqueEntityA.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1549
|
+
uniqueEntityA.uniques = ['test a'];
|
|
1550
|
+
// Saving entity...
|
|
1551
|
+
expect(await uniqueEntityA.$save()).toEqual(true);
|
|
1552
|
+
expect(uniqueEntityA.guid).not.toBeNull();
|
|
1553
|
+
// Creating entity...
|
|
1554
|
+
const uniqueEntityB = await TestModel.factory();
|
|
1555
|
+
uniqueEntityB.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1556
|
+
uniqueEntityB.uniques = ['test a'];
|
|
1557
|
+
// Saving entity...
|
|
1558
|
+
try {
|
|
1559
|
+
await uniqueEntityB.$save();
|
|
1560
|
+
throw Error("Shouldn't get past the uniqueness check.");
|
|
1561
|
+
}
|
|
1562
|
+
catch (e) {
|
|
1563
|
+
expect(e).toBeInstanceOf(EntityUniqueConstraintError);
|
|
1564
|
+
}
|
|
1565
|
+
expect(uniqueEntityB.guid).toBeNull();
|
|
1566
|
+
expect(await uniqueEntityA.$delete()).toEqual(true);
|
|
1567
|
+
});
|
|
1568
|
+
it('allows duplicate unique string if first transaction is rolled back', async () => {
|
|
1569
|
+
// Creating transaction entity...
|
|
1570
|
+
const tnymphA = await nymph.startTransaction('test-unique-a');
|
|
1571
|
+
const TestModelA = tnymphA.getEntityClass(TestModel);
|
|
1572
|
+
const uniqueEntityA = await TestModelA.factory();
|
|
1573
|
+
uniqueEntityA.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1574
|
+
uniqueEntityA.uniques = ['test a'];
|
|
1575
|
+
// Saving entity...
|
|
1576
|
+
expect(await uniqueEntityA.$save()).toEqual(true);
|
|
1577
|
+
expect(uniqueEntityA.guid).not.toBeNull();
|
|
1578
|
+
// Rolling back transaction...
|
|
1579
|
+
expect(await tnymphA.rollback('test-unique-a')).toEqual(true);
|
|
1580
|
+
// Creating transaction entity...
|
|
1581
|
+
const tnymphB = await nymph.startTransaction('test-unique-b');
|
|
1582
|
+
const TestModelB = tnymphB.getEntityClass(TestModel);
|
|
1583
|
+
const uniqueEntityB = await TestModelB.factory();
|
|
1584
|
+
uniqueEntityB.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1585
|
+
uniqueEntityB.uniques = ['test a'];
|
|
1586
|
+
// Saving entity...
|
|
1587
|
+
expect(await uniqueEntityB.$save()).toEqual(true);
|
|
1588
|
+
expect(uniqueEntityB.guid).not.toBeNull();
|
|
1589
|
+
expect(uniqueEntityA.guid).not.toEqual(uniqueEntityB.guid);
|
|
1590
|
+
expect(await tnymphB.commit('test-unique-b')).toEqual(true);
|
|
1591
|
+
const uniqueEntityACheck = await nymph.getEntity({ class: TestModel }, { type: '&', guid: uniqueEntityA.guid ?? '' });
|
|
1592
|
+
expect(uniqueEntityACheck).toBeNull();
|
|
1593
|
+
const uniqueEntityBCheck = await nymph.getEntity({ class: TestModel }, { type: '&', guid: uniqueEntityB.guid ?? '' });
|
|
1594
|
+
expect(uniqueEntityBCheck).not.toBeNull();
|
|
1595
|
+
if (uniqueEntityBCheck != null) {
|
|
1596
|
+
expect(await uniqueEntityBCheck.$delete()).toEqual(true);
|
|
1597
|
+
}
|
|
1598
|
+
});
|
|
1015
1599
|
}
|
|
1016
|
-
|
|
1017
|
-
function UIDTest(nymph, it) {
|
|
1600
|
+
export function UIDTest(nymph, it) {
|
|
1018
1601
|
it('delete old test data', async () => {
|
|
1019
1602
|
expect(await nymph.deleteUID('TestUID')).toEqual(true);
|
|
1020
1603
|
expect(await nymph.deleteUID('NewUID')).toEqual(true);
|
|
@@ -1045,10 +1628,9 @@ function UIDTest(nymph, it) {
|
|
|
1045
1628
|
expect(await nymph.getUID('TestUID')).toBeNull();
|
|
1046
1629
|
});
|
|
1047
1630
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
const
|
|
1051
|
-
const TestBModel = nymph.addEntityClass(testArtifacts_1.TestBModel);
|
|
1631
|
+
export function ExportImportTest(nymph, it) {
|
|
1632
|
+
const TestModel = nymph.addEntityClass(TestModelClass);
|
|
1633
|
+
const TestBModel = nymph.addEntityClass(TestBModelClass);
|
|
1052
1634
|
async function deleteTestData() {
|
|
1053
1635
|
let all = await nymph.getEntities({ class: TestModel });
|
|
1054
1636
|
expect(Array.isArray(all)).toEqual(true);
|
|
@@ -1073,21 +1655,34 @@ function ExportImportTest(nymph, it) {
|
|
|
1073
1655
|
const models = await nymph.getEntities({ class: TestModel });
|
|
1074
1656
|
const bmodels = await nymph.getEntities({ class: TestBModel });
|
|
1075
1657
|
expect(models.length).toEqual(30);
|
|
1076
|
-
expect(bmodels.length).toEqual(
|
|
1077
|
-
const
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1658
|
+
expect(bmodels.length).toEqual(30);
|
|
1659
|
+
for (const model of models) {
|
|
1660
|
+
expect(model.name).toMatch(/^Entity Test /);
|
|
1661
|
+
expect(model.null).toBeDefined();
|
|
1662
|
+
expect(model.null).toBeNull();
|
|
1663
|
+
expect(model.string).toEqual('test');
|
|
1664
|
+
expect(model.array).toEqual([
|
|
1665
|
+
'full',
|
|
1666
|
+
'of',
|
|
1667
|
+
'values',
|
|
1668
|
+
500,
|
|
1669
|
+
{ test: true },
|
|
1670
|
+
{ nullbyte: '\\\x00\u0000 \x00' },
|
|
1671
|
+
]);
|
|
1672
|
+
expect(model.match).toEqual(matchValue);
|
|
1673
|
+
expect(model.number).toEqual(30);
|
|
1674
|
+
expect(model.numberString).toEqual('30');
|
|
1675
|
+
expect(model.timestamp).toBeGreaterThanOrEqual(strtotime('-2 minutes'));
|
|
1676
|
+
expect(model.index).toMatch(/^\d+a$/);
|
|
1677
|
+
await model.reference?.$wake();
|
|
1678
|
+
expect(model.reference?.guid).not.toBeNull();
|
|
1679
|
+
expect(model.reference?.string).toEqual('another');
|
|
1680
|
+
expect(model.reference?.index).toMatch(/^\d+b$/);
|
|
1681
|
+
expect(model.index?.substring(0, -1)).toEqual(model.reference?.index?.substring(0, -1));
|
|
1682
|
+
expect(model.reference?.$inArray(bmodels)).toEqual(true);
|
|
1683
|
+
await Promise.all(model.refArray?.map((e) => e.$wake()) || []);
|
|
1684
|
+
expect(model.refArray?.[0].guid).not.toBeNull();
|
|
1685
|
+
expect(model.refArray?.[0].guid).toEqual(model.reference?.guid);
|
|
1091
1686
|
}
|
|
1092
1687
|
}
|
|
1093
1688
|
it('delete old test data', async () => {
|
|
@@ -1097,17 +1692,27 @@ function ExportImportTest(nymph, it) {
|
|
|
1097
1692
|
expect(await nymph.newUID('TestUID')).toEqual(1);
|
|
1098
1693
|
expect(await nymph.newUID('TestUID')).toEqual(2);
|
|
1099
1694
|
expect(await nymph.newUID('TestUID2')).toEqual(1);
|
|
1100
|
-
for (let i = 0; i <
|
|
1101
|
-
|
|
1102
|
-
const testEntity = await
|
|
1695
|
+
for (let i = 0; i < 30; i++) {
|
|
1696
|
+
// Creating entity...
|
|
1697
|
+
const testEntity = await TestModel.factory();
|
|
1698
|
+
// Saving entity...
|
|
1103
1699
|
testEntity.name = 'Entity Test ' + new Date().toLocaleString();
|
|
1104
1700
|
testEntity.null = null;
|
|
1105
1701
|
testEntity.string = 'test';
|
|
1106
|
-
testEntity.array = [
|
|
1702
|
+
testEntity.array = [
|
|
1703
|
+
'full',
|
|
1704
|
+
'of',
|
|
1705
|
+
'values',
|
|
1706
|
+
500,
|
|
1707
|
+
{ test: true },
|
|
1708
|
+
{ nullbyte: '\\\x00\u0000 \x00' },
|
|
1709
|
+
];
|
|
1710
|
+
testEntity.match = matchValue;
|
|
1107
1711
|
testEntity.number = 30;
|
|
1712
|
+
testEntity.numberString = '30';
|
|
1108
1713
|
testEntity.timestamp = Date.now();
|
|
1109
1714
|
testEntity.index = i + 'a';
|
|
1110
|
-
const entityReferenceTest = await
|
|
1715
|
+
const entityReferenceTest = await TestBModel.factory();
|
|
1111
1716
|
entityReferenceTest.string = 'another';
|
|
1112
1717
|
entityReferenceTest.index = i + 'b';
|
|
1113
1718
|
expect(await entityReferenceTest.$save()).toEqual(true);
|
|
@@ -1117,6 +1722,9 @@ function ExportImportTest(nymph, it) {
|
|
|
1117
1722
|
}
|
|
1118
1723
|
await checkEntityDataAndCount();
|
|
1119
1724
|
});
|
|
1725
|
+
it('needs migration', async () => {
|
|
1726
|
+
expect(await nymph.needsMigration()).toEqual(false);
|
|
1727
|
+
});
|
|
1120
1728
|
it('export data', async () => {
|
|
1121
1729
|
expect(await nymph.export(__dirname + '/testentityexport.nex')).toEqual(true);
|
|
1122
1730
|
});
|
|
@@ -1132,8 +1740,216 @@ function ExportImportTest(nymph, it) {
|
|
|
1132
1740
|
expect(bmodels.length).toEqual(0);
|
|
1133
1741
|
expect(await nymph.import(__dirname + '/testentityexport.nex')).toEqual(true);
|
|
1134
1742
|
await checkEntityDataAndCount();
|
|
1135
|
-
|
|
1743
|
+
fs.unlinkSync(__dirname + '/testentityexport.nex');
|
|
1744
|
+
});
|
|
1745
|
+
it('import tokens only', async () => {
|
|
1746
|
+
const model = await nymph.getEntity({ class: TestModel });
|
|
1747
|
+
expect(model).not.toBeNull();
|
|
1748
|
+
if (model != null) {
|
|
1749
|
+
const data = model.$getData(true);
|
|
1750
|
+
// These should not actually be saved in the DB.
|
|
1751
|
+
data.number = 424242424242;
|
|
1752
|
+
// But this should become searchable.
|
|
1753
|
+
data.search = 'peanuts and pickles on a hot bun';
|
|
1754
|
+
const sdata = Object.fromEntries(Object.entries(data).map(([name, value]) => [
|
|
1755
|
+
name,
|
|
1756
|
+
JSON.stringify(value),
|
|
1757
|
+
]));
|
|
1758
|
+
if (model.guid == null || model.cdate == null || model.mdate == null) {
|
|
1759
|
+
throw new Error('Model data is wrong.');
|
|
1760
|
+
}
|
|
1761
|
+
await nymph.importEntityTokens({
|
|
1762
|
+
guid: model.guid,
|
|
1763
|
+
// Again, these should not actually be changed in the DB.
|
|
1764
|
+
cdate: model.cdate + 1000,
|
|
1765
|
+
mdate: model.mdate + 1000,
|
|
1766
|
+
tags: [...model.tags, 'helicopter'],
|
|
1767
|
+
sdata,
|
|
1768
|
+
etype: TestModel.ETYPE,
|
|
1769
|
+
});
|
|
1770
|
+
const modelCheck = await nymph.getEntity({ class: TestModel }, { type: '&', search: ['search', '"peanuts and pickles on a hot bun"'] });
|
|
1771
|
+
expect(modelCheck?.guid).toEqual(model.guid);
|
|
1772
|
+
expect(modelCheck?.cdate).toEqual(model.cdate);
|
|
1773
|
+
expect(modelCheck?.mdate).toEqual(model.mdate);
|
|
1774
|
+
expect(modelCheck?.$hasTag('helicopter')).toEqual(false);
|
|
1775
|
+
expect(modelCheck?.number).not.toEqual(424242424242);
|
|
1776
|
+
expect(modelCheck?.search).not.toEqual('peanuts and pickles on a hot bun');
|
|
1777
|
+
}
|
|
1136
1778
|
});
|
|
1137
1779
|
}
|
|
1138
|
-
|
|
1780
|
+
const matchValue = `Hello, my name is Edward McCheese. It is a pleasure to meet you. As you can see, I have several hats of the most pleasant nature.
|
|
1781
|
+
|
|
1782
|
+
This one's email address is nice_hat-wednesday+newyork@im-a-hat.hat.
|
|
1783
|
+
This one's phone number is (555) 555-1818.
|
|
1784
|
+
This one's zip code is 92064.
|
|
1785
|
+
This one's favorite emojis are 🔥❤️😊😂⭐🤔
|
|
1786
|
+
|
|
1787
|
+
These hats are absolutely fantastic.
|
|
1788
|
+
|
|
1789
|
+
\x00\x00\x00
|
|
1790
|
+
|
|
1791
|
+
Lorem ipsum odor amet, consectetuer adipiscing elit. Metus ad mattis sit pretium per, dignissim imperdiet luctus. Congue rhoncus turpis etiam aenean ultricies dapibus justo nunc. Netus non primis quis habitasse lacus. Nascetur dapibus sociosqu ridiculus primis; elementum netus consectetur ridiculus litora. Tristique facilisis erat ex class nulla cursus amet. Metus vitae tempor euismod vel; ullamcorper ac quisque vestibulum. Mauris libero pulvinar facilisi eros natoque massa.
|
|
1792
|
+
|
|
1793
|
+
Nunc vel hac nec tristique vivamus. Leo volutpat convallis eget integer tellus cubilia tincidunt malesuada? Consequat elit nisi tristique vehicula cubilia maecenas metus facilisi malesuada. In mattis euismod ad magnis fusce. Nisi congue sociosqu rhoncus lobortis fringilla sollicitudin at platea. Iaculis ut et varius metus eleifend laoreet hac odio libero. Non ridiculus tempus ultricies nullam curabitur.
|
|
1794
|
+
|
|
1795
|
+
Amet pellentesque aliquam placerat; vestibulum blandit platea porttitor pulvinar. Tellus tristique ad morbi in ac placerat luctus. Ante efficitur inceptos commodo lacus sodales sit varius nunc consequat. Senectus non vel est convallis mauris. Venenatis feugiat massa nostra, purus class primis sodales odio. Risus nulla integer feugiat ridiculus porta nascetur. Rutrum tincidunt enim parturient libero nisl ante sagittis nisi. Cubilia massa non vehicula vehicula amet parturient pellentesque. Habitant dapibus fames lectus pretium rhoncus.
|
|
1796
|
+
|
|
1797
|
+
Ridiculus nascetur mauris iaculis hendrerit ridiculus gravida auctor in. Class suscipit augue finibus semper vulputate nec. Tristique mi eu praesent commodo fermentum inceptos penatibus lobortis. Libero enim orci ultricies egestas ut pellentesque. Laoreet massa ad curabitur tellus libero laoreet habitasse enim nascetur. Iaculis euismod a euismod conubia purus. Commodo condimentum ultrices lorem ligula aenean; netus mattis sem non.
|
|
1798
|
+
|
|
1799
|
+
Curabitur duis imperdiet mus integer vel bibendum; fusce malesuada. Dignissim duis himenaeos primis odio, congue pharetra? Egestas mus sit eget proin quis. Neque dapibus dapibus nam sociosqu; maecenas viverra himenaeos. Himenaeos faucibus himenaeos faucibus ex litora eros faucibus cras. Maximus scelerisque nullam nunc congue fringilla. Nisi eu magna erat morbi cras enim amet litora. Nostra primis vitae arcu, accumsan sollicitudin curabitur. Potenti sit vel vehicula metus leo id. Etiam blandit quisque nam orci; neque lacinia rutrum.
|
|
1800
|
+
|
|
1801
|
+
Aliquam mollis varius hendrerit sem eleifend fermentum. Sapien rutrum condimentum inceptos ex feugiat consectetur mollis magna diam. Natoque enim nisi, ex risus finibus lacinia conubia vivamus suscipit. Habitasse interdum lorem ante, bibendum posuere dis. Lacus porttitor sapien proin; consequat velit ipsum venenatis. Vivamus porta mattis morbi nunc torquent neque. Senectus vehicula tincidunt parturient fringilla id amet urna libero pharetra.
|
|
1802
|
+
|
|
1803
|
+
Faucibus netus tincidunt et viverra augue ligula est quis. Ipsum tempus vehicula tortor dis tortor ad. Ex tincidunt torquent eleifend aenean urna commodo. Quam nullam imperdiet volutpat vel condimentum cubilia sociosqu. Etiam tempor sapien mattis, venenatis aptent id risus. Efficitur luctus vel; nam ut commodo sociosqu hendrerit. Quisque placerat gravida rhoncus blandit vitae. Himenaeos id risus est mollis aliquet nam curabitur.
|
|
1804
|
+
|
|
1805
|
+
Habitasse sed est fames quis lobortis leo mattis. Nisl cursus tincidunt cursus felis porttitor. Ante integer turpis non class lobortis suscipit. Condimentum velit vulputate quis sapien, lacus magna adipiscing nec primis. Blandit consequat ipsum nostra dignissim; tincidunt torquent fames. Ac faucibus elit iaculis duis lobortis. Euismod facilisi massa turpis mus neque. Class vulputate quisque elementum suscipit nostra tempus adipiscing. Malesuada himenaeos finibus ad inceptos volutpat scelerisque inceptos.
|
|
1806
|
+
|
|
1807
|
+
Natoque platea at feugiat cras tellus facilisi suspendisse lacinia maximus. Duis vestibulum eget molestie turpis risus dapibus dignissim torquent? Nulla nibh aptent fringilla scelerisque euismod mauris ornare. Orci finibus taciti habitasse fringilla laoreet convallis. Class sed fringilla eget quisque sit auctor. Id cursus mauris praesent maecenas iaculis. Ullamcorper luctus habitant ultrices pharetra etiam mattis morbi fringilla lorem.
|
|
1808
|
+
|
|
1809
|
+
Pharetra porta orci ridiculus inceptos eleifend sem ante quis. Molestie velit penatibus libero per sem litora congue. Porta quis egestas vivamus vitae potenti ornare. Elit molestie nullam vitae quam viverra. Nisl fringilla massa ridiculus donec ridiculus sed magnis. Cursus ad enim consequat ultricies tortor rhoncus pellentesque augue. Netus facilisis tempor elementum interdum at sagittis habitasse. Pretium imperdiet duis diam ullamcorper donec at suscipit. Id per inceptos ac luctus massa imperdiet tempor. Parturient libero suscipit non tempor ligula ullamcorper placerat varius.
|
|
1810
|
+
|
|
1811
|
+
Libero duis suspendisse cubilia rhoncus scelerisque faucibus mattis. Leo fusce urna at per inceptos vel lobortis. Quisque ex duis euismod dictum hac nibh eros. Penatibus eleifend tellus donec elit primis phasellus habitant dictum. Imperdiet consequat facilisi massa, lacus gravida sodales id sapien. Ornare sapien sit convallis suscipit nunc enim. Tempus at vitae class sollicitudin proin. Dolor aenean felis netus consectetur mattis phasellus vestibulum. Orci fringilla sodales montes sed himenaeos ex massa natoque porttitor.
|
|
1812
|
+
|
|
1813
|
+
Mus condimentum dui mollis dolor accumsan ligula pretium? Est phasellus platea iaculis vehicula et eros vel rutrum placerat. Nulla laoreet faucibus; congue netus magna senectus lectus dictum. Sodales aliquam eget himenaeos adipiscing, tempor feugiat. Lorem pellentesque iaculis fames lectus cubilia ornare sagittis rhoncus? Bibendum viverra tellus libero congue dignissim metus tellus aenean ultrices. Sollicitudin cras sollicitudin mattis lacus facilisis fermentum scelerisque porttitor rutrum.
|
|
1814
|
+
|
|
1815
|
+
Sapien aptent fames curae, consectetur dapibus mauris sollicitudin tellus. Laoreet etiam dignissim, suscipit platea libero vitae taciti eu nec. Donec lobortis metus nisi; est enim himenaeos molestie tellus sapien. Sapien tellus rhoncus blandit fusce hendrerit feugiat. Maximus sit hendrerit tincidunt nec imperdiet hendrerit semper suscipit. Quam augue proin netus rutrum et sem. Neque penatibus cubilia nec metus porta. Ornare pulvinar quam auctor, elit curae ad donec dis. Egestas aptent non tortor potenti morbi mauris.
|
|
1816
|
+
|
|
1817
|
+
Montes dui in pharetra primis consequat ante integer. Vulputate libero gravida rutrum tortor suscipit massa! Netus rhoncus platea torquent dapibus consectetur suspendisse etiam sociosqu. Quis placerat mauris et quam nascetur. Dictumst mi rutrum justo vitae ultricies feugiat nulla faucibus morbi. Consectetur nec condimentum euismod sodales nisi purus; finibus elementum facilisi.
|
|
1818
|
+
|
|
1819
|
+
Senectus mus faucibus ut morbi eu maximus. Turpis tincidunt sodales sociosqu lorem amet pulvinar laoreet faucibus. Mus bibendum vulputate hendrerit sollicitudin eu ridiculus posuere augue leo? Cubilia nostra consequat; fusce egestas himenaeos class ornare nec. Est montes tortor vivamus congue inceptos erat mi eget pellentesque. Amet vulputate fringilla aliquet fames tristique. Rutrum malesuada dapibus vehicula risus nunc torquent habitant turpis habitant. Ipsum proin viverra adipiscing cras et augue hendrerit. Efficitur euismod aliquam habitant; sit nisl potenti.
|
|
1820
|
+
|
|
1821
|
+
Conubia dignissim metus phasellus tristique augue, nullam quam finibus. Dignissim vel enim mattis praesent penatibus. Sapien pharetra curae torquent turpis fermentum feugiat facilisis nisi. Lacinia justo ante mauris finibus vitae ante efficitur dis. Urna gravida conubia amet rhoncus felis ut lorem placerat. Quisque fermentum suscipit aenean nisi suscipit ac? Quis ornare faucibus amet conubia justo maximus hendrerit phasellus aenean. Ex vivamus vulputate in mollis mauris praesent vehicula erat neque.
|
|
1822
|
+
|
|
1823
|
+
Orci nullam commodo habitant volutpat per tincidunt mus sit. Nisi cubilia fringilla viverra at orci magnis massa nam orci. Duis iaculis sapien nulla nascetur elit porta fermentum. Amus libero vivamus vel finibus magnis placerat himenaeos. Integer posuere suscipit non vulputate enim. Conubia id lobortis habitasse luctus odio maecenas enim conubia non. Mus egestas massa platea nullam sociosqu, magnis cras. Quam placerat nisi dui gravida ultricies, facilisis eu pharetra vivamus.
|
|
1824
|
+
|
|
1825
|
+
Fusce maecenas dis finibus senectus nascetur tortor. Nec rhoncus pretium vivamus donec vel ligula curabitur. Velit dis laoreet aenean, fusce metus blandit erat. Ligula purus natoque, arcu finibus tincidunt efficitur dolor curabitur. Ac risus et ipsum; consequat integer phasellus diam. Praesent ipsum gravida placerat porta volutpat tincidunt maximus sapien. Phasellus gravida orci enim velit condimentum.
|
|
1826
|
+
|
|
1827
|
+
Dui id laoreet penatibus orci sit a. Iaculis dis porttitor luctus; lacus dignissim quam commodo lorem. Nullam dictum quisque accumsan porttitor tortor fusce aenean. Aliquet quisque ultricies malesuada auctor facilisi tristique. Dolor nulla conubia ultricies odio ad. Nunc consectetur venenatis consequat nisi habitant. Praesent accumsan scelerisque morbi aliquam sociosqu auctor, nostra aenean.
|
|
1828
|
+
|
|
1829
|
+
Mauris amet conubia egestas eu posuere nullam. Est neque dictum in, lacus aliquam ultrices vestibulum. Dapibus dis habitasse cras conubia felis nibh. Egestas nisl iaculis nostra neque enim, ridiculus praesent. Consectetur eleifend eu mus; elit sed pellentesque fringilla. Ullamcorper hendrerit nibh aptent per congue libero ultrices eget. Mollis velit ad tortor lobortis ipsum.
|
|
1830
|
+
|
|
1831
|
+
Tristique neque justo potenti himenaeos; pellentesque nam vehicula. Maximus etiam ut nullam semper; fames curabitur quam ad morbi. Interdum curabitur platea augue porttitor a gravida. Leo imperdiet id aenean sit; habitasse quam tempus pellentesque? Nostra leo aenean amet lectus ultricies ridiculus nascetur ullamcorper. Taciti in iaculis quam nascetur proin varius eget vehicula.
|
|
1832
|
+
|
|
1833
|
+
Mattis hendrerit tempus interdum diam elementum primis augue phasellus sociosqu. Imperdiet pulvinar imperdiet lacinia posuere class magnis. Montes viverra scelerisque laoreet sociosqu proin lacus. Nam id justo praesent curabitur nam accumsan imperdiet commodo. Sociosqu netus sapien proin interdum ac. Dapibus tempor et sodales, natoque consequat torquent.
|
|
1834
|
+
|
|
1835
|
+
Lectus ultricies amet bibendum blandit finibus erat pellentesque. Nam quis ultrices curae; lorem gravida malesuada velit taciti enim. Facilisis fermentum suspendisse leo tristique litora dapibus rhoncus convallis. Netus iaculis eleifend viverra urna, vulputate ac convallis. Faucibus torquent dictum, nisl sed parturient libero. Ornare class habitant per consequat adipiscing rhoncus feugiat.
|
|
1836
|
+
|
|
1837
|
+
Proin molestie nullam eros parturient parturient curabitur aliquet. Rhoncus mus aenean sem aliquet sem finibus neque rutrum commodo. Efficitur litora lobortis nascetur adipiscing curae faucibus? Bibendum leo velit augue; potenti primis malesuada lacus ipsum. Facilisi potenti facilisis nam tempor consequat. Magnis suspendisse primis duis quam; suscipit quis fermentum phasellus. Massa ridiculus habitasse ipsum arcu sit maecenas gravida nisi? Dolor egestas lacinia lacinia libero nam curae suspendisse purus. Tristique inceptos curae netus scelerisque magna hendrerit commodo quis parturient. Eget accumsan erat sociosqu vestibulum platea turpis habitasse.
|
|
1838
|
+
|
|
1839
|
+
Maximus dignissim sed conubia a ipsum nullam condimentum dictumst. Suspendisse congue phasellus congue lacus sollicitudin senectus curae. Consequat sagittis in fringilla suscipit scelerisque suscipit. Rhoncus pharetra sodales malesuada sollicitudin lectus. Est primis pretium finibus felis pharetra nulla sapien lacinia. Nunc lorem aptent tristique quisque etiam posuere non ullamcorper. Potenti mus sed mus; non id eleifend pellentesque magnis.
|
|
1840
|
+
|
|
1841
|
+
Iaculis morbi mattis; ornare tincidunt neque mus egestas consectetur ultrices. Porta dapibus pretium, vulputate dis amet neque. Posuere auctor lacinia maecenas ridiculus ullamcorper tempus egestas cubilia nec. Cursus nulla lacinia mi facilisi, nisl tempor. Tempus elementum laoreet magnis neque morbi felis per. Suspendisse lectus vitae nunc amet himenaeos euismod aliquam. Quisque integer dictum aenean fermentum dictumst torquent.
|
|
1842
|
+
|
|
1843
|
+
Sociosqu per suspendisse augue phasellus velit dapibus parturient. At sit eu finibus posuere tincidunt. Phasellus duis scelerisque scelerisque taciti est venenatis. Arcu habitant augue amet eget maximus torquent. Eget gravida ut quisque ligula vel mus. Erat quis himenaeos; velit eget varius viverra interdum. Neque dapibus malesuada est a gravida libero integer aptent. Semper eleifend per at magnis, laoreet nibh orci vel ligula.
|
|
1844
|
+
|
|
1845
|
+
Odio purus finibus inceptos malesuada duis. Neque magnis est laoreet nibh gravida sagittis ullamcorper sodales. Parturient ultricies mattis lacus risus laoreet praesent. Tincidunt eleifend quis sagittis id nascetur. Nam scelerisque varius feugiat phasellus enim mauris nam. Tortor iaculis et cras; blandit sollicitudin pellentesque justo. Nam lacinia volutpat fusce nibh mollis; himenaeos iaculis. Vulputate dictum mattis sollicitudin accumsan at hendrerit.
|
|
1846
|
+
|
|
1847
|
+
Ipsum augue faucibus senectus porta dapibus metus. Netus sem amet nullam fermentum in dolor bibendum. Lacus quis enim vivamus enim risus elit suspendisse arcu. Penatibus proin pellentesque consequat nibh turpis fusce. Potenti sociosqu nunc tempor amet torquent. Aliquet porttitor adipiscing parturient curabitur hac? Condimentum morbi netus erat class hendrerit aptent. Placerat viverra molestie at eget donec quisque. Varius sem erat dolor, urna nunc ac duis inceptos maximus.
|
|
1848
|
+
|
|
1849
|
+
Nostra adipiscing dapibus eros vivamus accumsan elementum curae dignissim dignissim. Iaculis quisque fusce at conubia est habitant ipsum. Porttitor libero lobortis lobortis habitasse quis quisque nunc euismod aenean. Bibendum nullam volutpat quam vitae felis sit. Mauris bibendum nulla litora nec id, elit lacinia. Orci odio nunc est ante commodo dis quis diam convallis? Mattis a per cras amet egestas ex pellentesque nascetur augue. Egestas per massa per non metus hendrerit feugiat eu?
|
|
1850
|
+
|
|
1851
|
+
Praesent habitasse est elementum mattis potenti. Fermentum interdum enim orci dui faucibus sodales nisi mus. Tortor facilisi nunc potenti; dignissim magna varius! Risus cursus ornare tincidunt a feugiat massa cubilia. Sociosqu quis pharetra efficitur lorem ornare sapien arcu euismod. Elementum donec maecenas praesent scelerisque viverra mi natoque. Lacinia nibh eu commodo ut class blandit magnis.
|
|
1852
|
+
|
|
1853
|
+
Ullamcorper himenaeos mollis nostra placerat quam pellentesque nibh. Curae posuere cras dis senectus fringilla congue ipsum sit. Eros maecenas duis morbi consequat himenaeos ridiculus purus erat. Nascetur maximus massa eros class phasellus integer sed gravida. Vel donec lacinia donec curabitur penatibus integer ornare. Varius quam lectus magna per a mauris.
|
|
1854
|
+
|
|
1855
|
+
Imperdiet tempus malesuada ultrices egestas taciti nibh elit lacus. Nunc tempus tellus vitae duis rhoncus leo facilisis. Sapien nec mi lacus mi aliquet. Diam convallis fringilla libero duis integer integer dictum vel. Dolor montes nibh sapien dapibus ultrices praesent. Aeuismod phasellus taciti elit vehicula sit sociosqu. Lobortis neque urna dignissim penatibus felis vulputate. Primis magnis placerat, ligula massa facilisis nec.
|
|
1856
|
+
|
|
1857
|
+
Duis interdum himenaeos dis nisl et tortor condimentum accumsan. Laoreet amet fusce dis malesuada iaculis maximus fringilla. Conubia mus nibh felis vestibulum ad convallis mollis. Metus vivamus lobortis habitasse id nam. Egestas pretium eu penatibus consectetur malesuada congue tempus fusce. Rutrum neque pulvinar duis ligula fermentum malesuada. Tincidunt mollis molestie imperdiet ridiculus pharetra maximus sodales curabitur.
|
|
1858
|
+
|
|
1859
|
+
Sem nec integer fusce neque sagittis. Rutrum ipsum ante; urna enim primis consectetur nulla. Arcu ligula lectus varius magna ipsum, et dictum. Pharetra dignissim inceptos tristique natoque tempor volutpat. Luctus tristique himenaeos duis orci maecenas vel morbi. Habitasse a lacinia dignissim commodo elementum maecenas eu mollis. Fermentum tellus sem condimentum mattis elit lectus. Platea fusce arcu cras varius natoque? Volutpat tincidunt ridiculus mus massa ante dis sem ornare magna. Bibendum ornare ultrices proin efficitur; nascetur risus arcu.
|
|
1860
|
+
|
|
1861
|
+
Orci erat orci amet mollis venenatis. Feugiat torquent ex mattis, inceptos etiam integer. Class senectus aptent vivamus, semper dolor nisi at pretium volutpat. Natoque semper enim enim primis ultricies, pharetra pulvinar. Natoque litora tortor accumsan ridiculus lacinia integer; aliquet penatibus ridiculus. Placerat vestibulum justo tristique sapien senectus, et interdum et ridiculus. Urna aenean vel himenaeos; finibus a est efficitur donec. Dictum egestas quis fusce arcu; sapien himenaeos pretium congue. Semper et sapien nisi nascetur venenatis eros integer blandit.
|
|
1862
|
+
|
|
1863
|
+
Arcu per phasellus vehicula ad molestie? Eget arcu eget inceptos, eu ullamcorper diam. Gravida placerat elit ut hendrerit odio. Est lobortis imperdiet venenatis primis a. Facilisis integer maecenas adipiscing metus, rutrum curabitur. Dolor adipiscing himenaeos senectus tempus faucibus cras.
|
|
1864
|
+
|
|
1865
|
+
Massa torquent torquent ullamcorper erat nisl parturient primis eu pulvinar! Ridiculus sollicitudin dis eu, laoreet praesent hendrerit platea euismod. Lacinia dignissim suspendisse sagittis eu rutrum himenaeos curae massa diam. Platea ornare ridiculus consequat curabitur augue vestibulum ridiculus. Vel consectetur vivamus accumsan risus elementum? Imperdiet nascetur efficitur aliquam habitasse nascetur. Hendrerit quisque magnis in lacinia quis mauris.
|
|
1866
|
+
|
|
1867
|
+
Molestie fermentum blandit, viverra condimentum purus himenaeos. Fermentum congue a suspendisse ornare semper laoreet. Pharetra lacus non, iaculis ad taciti varius. Etiam nam risus vestibulum curabitur facilisis mattis, lorem hac id. Dignissim nibh tempor quam porta lectus nunc tincidunt aliquet. Tortor maximus maximus natoque nam magna torquent nec lectus mus. Vel fermentum semper vulputate penatibus vel purus.
|
|
1868
|
+
|
|
1869
|
+
Fermentum tincidunt penatibus platea himenaeos etiam sodales ad erat posuere. Vehicula vulputate sem blandit nullam sem. Condimentum eget lacus ad malesuada augue dui justo. Lobortis quis mauris pellentesque quam interdum sagittis. Nulla ullamcorper aptent hendrerit fusce hendrerit, cras cras magna. Ex quam torquent, congue dis est vulputate lacinia. Dignissim proin lacinia platea tortor elementum nullam. Purus natoque scelerisque habitant vestibulum; metus dui neque ipsum. Pellentesque augue montes fringilla et, maecenas habitant a.
|
|
1870
|
+
|
|
1871
|
+
Quam sapien eu scelerisque tristique, integer in rutrum gravida. Egestas lacinia nisi praesent turpis lacus maximus mus gravida. Dolor eget ultrices rhoncus velit; mollis id. Mi vulputate sed blandit nullam parturient venenatis. Neque vulputate iaculis nascetur felis fames ipsum adipiscing nullam? Vitae faucibus elit congue himenaeos orci volutpat nam. Magna tempus convallis vivamus eu semper. Egestas curabitur integer quis habitasse id taciti hac sociosqu morbi. Duis felis cursus potenti blandit cras dolor pharetra.
|
|
1872
|
+
|
|
1873
|
+
Ultricies vel primis nec mus malesuada congue? Habitasse semper mus ultricies; fermentum himenaeos placerat sodales. Platea sapien malesuada dignissim suscipit dis cras. Etiam odio pharetra metus donec odio natoque. Cras diam curae dapibus accumsan tortor mi laoreet. Ex mollis massa inceptos inceptos adipiscing. Cras rhoncus natoque accumsan augue enim. Parturient porttitor habitant semper platea elementum dictum ornare? Sociosqu blandit nullam vivamus elementum semper himenaeos.
|
|
1874
|
+
|
|
1875
|
+
Orci elit aliquam luctus habitant interdum. Tellus sollicitudin aliquam donec potenti praesent augue magnis auctor. Mattis faucibus iaculis etiam imperdiet lectus ad habitasse sollicitudin ac. Consequat maecenas quam dis adipiscing neque sociosqu. Ullamcorper in praesent himenaeos purus blandit nibh. Dignissim platea amet urna laoreet sociosqu lacinia accumsan consectetur risus. Adipiscing nullam arcu lobortis mi scelerisque feugiat non. Accumsan lacinia urna sit urna tincidunt nam pulvinar urna. Tellus cursus ac himenaeos sed aptent phasellus.
|
|
1876
|
+
|
|
1877
|
+
Scelerisque curabitur eget morbi leo phasellus morbi magnis. Elit nunc non vulputate eget at. Viverra efficitur dignissim fames ut condimentum tincidunt elementum lacus egestas. Dictum phasellus leo auctor dui diam. Sollicitudin placerat elit vehicula vulputate et at eleifend ullamcorper. Primis diam hac class leo justo etiam magnis. Justo maximus venenatis facilisis egestas hendrerit aptent arcu tortor consectetur. Consequat mus curabitur nisl; blandit enim at bibendum tempor bibendum. Ad nam arcu vehicula himenaeos sociosqu eu faucibus accumsan.
|
|
1878
|
+
|
|
1879
|
+
Maximus malesuada faucibus phasellus donec ligula. Rutrum pellentesque ultricies nullam; aenean scelerisque elementum. Porta luctus consectetur pharetra consequat varius. Ut dapibus senectus venenatis scelerisque fames ligula congue. Magna hendrerit faucibus ultricies tincidunt phasellus pellentesque, maecenas consequat! Malesuada senectus praesent sed condimentum aenean mi. Interdum sollicitudin mattis, purus vitae netus gravida. Nullam magna risus leo sit urna aenean.
|
|
1880
|
+
|
|
1881
|
+
Ut lacinia potenti vel varius habitant mus nullam adipiscing. Commodo potenti conubia hendrerit enim massa ad blandit. Nisl a massa nunc risus, condimentum enim. Hac aenean massa lacinia lobortis ad dolor sem. Nisl ex interdum blandit pulvinar pellentesque lorem. Sapien proin malesuada netus parturient pulvinar nec. Ex semper amet sem maximus blandit cras felis. Donec tellus auctor eleifend placerat natoque. Rutrum maecenas sollicitudin nisl consectetur in nulla rhoncus. Id rhoncus nec mi non lacinia leo efficitur nisi.
|
|
1882
|
+
|
|
1883
|
+
Dolor non phasellus id nascetur id nisi litora cubilia interdum. Lectus dolor sodales eu nulla porttitor placerat vulputate. Praesent ullamcorper consequat nulla torquent facilisis nunc. Rhoncus augue eleifend mauris erat duis varius felis. Dignissim nunc pulvinar vehicula dignissim maximus elit metus senectus. Venenatis conubia pulvinar commodo dui montes cubilia.
|
|
1884
|
+
|
|
1885
|
+
Cursus velit lacus aenean elit conubia. Velit in inceptos enim, elit lobortis est facilisis. Suscipit cursus dictum enim libero neque dolor himenaeos eu. Porta in integer praesent quisque quis sit. Primis velit tempus sit curae vehicula porttitor. Scelerisque nisi diam vehicula mi fusce dictum. Tincidunt mus eleifend commodo ridiculus adipiscing.
|
|
1886
|
+
|
|
1887
|
+
Pellentesque quis dignissim euismod in fermentum quam lobortis porta. Dis euismod ultricies montes odio sapien condimentum integer per. Torquent nascetur ante ante; diam ultrices nec habitant. Augue congue a conubia commodo ultricies tortor. Quis ridiculus netus vivamus dictumst efficitur parturient hendrerit. Facilisis ultrices suspendisse elit sodales eleifend maecenas tempor. Habitasse platea congue ac, pretium augue odio interdum netus. Mattis odio mi leo integer nisi diam phasellus elementum. Tortor himenaeos curabitur enim sit ac mi dictumst faucibus sociosqu.
|
|
1888
|
+
|
|
1889
|
+
Duis ex viverra auctor praesent elit ac. Sit ex at cubilia aenean scelerisque finibus ridiculus. Hendrerit imperdiet potenti erat risus commodo. Sit donec ullamcorper facilisi neque varius, suscipit malesuada hac. Nulla lacinia pulvinar non volutpat pellentesque lobortis ultrices dis. Faucibus luctus fusce, aliquam magnis pharetra sed dui nulla viverra. Lectus hendrerit eu pellentesque nostra mauris suspendisse himenaeos. Lectus bibendum inceptos commodo nulla magnis proin.`;
|
|
1890
|
+
const searchValue = `In Congress, July 4, 1776
|
|
1891
|
+
|
|
1892
|
+
The unanimous Declaration of the thirteen united States of America, When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation.
|
|
1893
|
+
|
|
1894
|
+
We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness.--That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, --That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient causes; and accordingly all experience hath shewn, that mankind are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms to which they are accustomed. But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security.--Such has been the patient sufferance of these Colonies; and such is now the necessity which constrains them to alter their former Systems of Government. The history of the present King of Great Britain is a history of repeated injuries and usurpations, all having in direct object the establishment of an absolute Tyranny over these States. To prove this, let Facts be submitted to a candid world.
|
|
1895
|
+
|
|
1896
|
+
He has refused his Assent to Laws, the most wholesome and necessary for the public good.
|
|
1897
|
+
|
|
1898
|
+
He has forbidden his Governors to pass Laws of immediate and pressing importance, unless suspended in their operation till his Assent should be obtained; and when so suspended, he has utterly neglected to attend to them.
|
|
1899
|
+
|
|
1900
|
+
He has refused to pass other Laws for the accommodation of large districts of people, unless those people would relinquish the right of Representation in the Legislature, a right inestimable to them and formidable to tyrants only.
|
|
1901
|
+
|
|
1902
|
+
He has called together legislative bodies at places unusual, uncomfortable, and distant from the depository of their public Records, for the sole purpose of fatiguing them into compliance with his measures.
|
|
1903
|
+
|
|
1904
|
+
He has dissolved Representative Houses repeatedly, for opposing with manly firmness his invasions on the rights of the people.
|
|
1905
|
+
|
|
1906
|
+
He has refused for a long time, after such dissolutions, to cause others to be elected; whereby the Legislative powers, incapable of Annihilation, have returned to the People at large for their exercise; the State remaining in the mean time exposed to all the dangers of invasion from without, and convulsions within.
|
|
1907
|
+
|
|
1908
|
+
He has endeavoured to prevent the population of these States; for that purpose obstructing the Laws for Naturalization of Foreigners; refusing to pass others to encourage their migrations hither, and raising the conditions of new Appropriations of Lands.
|
|
1909
|
+
|
|
1910
|
+
He has obstructed the Administration of Justice, by refusing his Assent to Laws for establishing Judiciary powers.
|
|
1911
|
+
|
|
1912
|
+
He has made Judges dependent on his Will alone, for the tenure of their offices, and the amount and payment of their salaries.
|
|
1913
|
+
|
|
1914
|
+
He has erected a multitude of New Offices, and sent hither swarms of Officers to harrass our people, and eat out their substance.
|
|
1915
|
+
|
|
1916
|
+
He has kept among us, in times of peace, Standing Armies without the Consent of our legislatures.
|
|
1917
|
+
|
|
1918
|
+
He has affected to render the Military independent of and superior to the Civil power.
|
|
1919
|
+
|
|
1920
|
+
He has combined with others to subject us to a jurisdiction foreign to our constitution, and unacknowledged by our laws; giving his Assent to their Acts of pretended Legislation:
|
|
1921
|
+
|
|
1922
|
+
For Quartering large bodies of armed troops among us:
|
|
1923
|
+
|
|
1924
|
+
For protecting them, by a mock Trial, from punishment for any Murders which they should commit on the Inhabitants of these States:
|
|
1925
|
+
|
|
1926
|
+
For cutting off our Trade with all parts of the world:
|
|
1927
|
+
|
|
1928
|
+
For imposing Taxes on us without our Consent:
|
|
1929
|
+
|
|
1930
|
+
For depriving us in many cases, of the benefits of Trial by Jury:
|
|
1931
|
+
|
|
1932
|
+
For transporting us beyond Seas to be tried for pretended offences:
|
|
1933
|
+
|
|
1934
|
+
For abolishing the free System of English Laws in a neighbouring Province, establishing therein an Arbitrary government, and enlarging its Boundaries so as to render it at once an example and fit instrument for introducing the same absolute rule into these Colonies:
|
|
1935
|
+
|
|
1936
|
+
For taking away our Charters, abolishing our most valuable Laws, and altering fundamentally the Forms of our Governments:
|
|
1937
|
+
|
|
1938
|
+
For suspending our own Legislatures, and declaring themselves invested with power to legislate for us in all cases whatsoever.
|
|
1939
|
+
|
|
1940
|
+
He has abdicated Government here, by declaring us out of his Protection and waging War against us.
|
|
1941
|
+
|
|
1942
|
+
He has plundered our seas, ravaged our Coasts, burnt our towns, and destroyed the lives of our people.
|
|
1943
|
+
|
|
1944
|
+
He is at this time transporting large Armies of foreign Mercenaries to compleat the works of death, desolation and tyranny, already begun with circumstances of Cruelty & perfidy scarcely paralleled in the most barbarous ages, and totally unworthy the Head of a civilized nation.
|
|
1945
|
+
|
|
1946
|
+
He has constrained our fellow Citizens taken Captive on the high Seas to bear Arms against their Country, to become the executioners of their friends and Brethren, or to fall themselves by their Hands.
|
|
1947
|
+
|
|
1948
|
+
He has excited domestic insurrections amongst us, and has endeavoured to bring on the inhabitants of our frontiers, the merciless Indian Savages, whose known rule of warfare, is an undistinguished destruction of all ages, sexes and conditions.
|
|
1949
|
+
|
|
1950
|
+
In every stage of these Oppressions We have Petitioned for Redress in the most humble terms: Our repeated Petitions have been answered only by repeated injury. A Prince, whose character is thus marked by every act which may define a Tyrant, is unfit to be the ruler of a free people.
|
|
1951
|
+
|
|
1952
|
+
Nor have We been wanting in attentions to our Brittish brethren. We have warned them from time to time of attempts by their legislature to extend an unwarrantable jurisdiction over us. We have reminded them of the circumstances of our emigration and settlement here. We have appealed to their native justice and magnanimity, and we have conjured them by the ties of our common kindred to disavow these usurpations, which, would inevitably interrupt our connections and correspondence. They too have been deaf to the voice of justice and of consanguinity. We must, therefore, acquiesce in the necessity, which denounces our Separation, and hold them, as we hold the rest of mankind, Enemies in War, in Peace Friends.
|
|
1953
|
+
|
|
1954
|
+
We, therefore, the Representatives of the united States of America, in General Congress, Assembled, appealing to the Supreme Judge of the world for the rectitude of our intentions, do, in the Name, and by Authority of the good People of these Colonies, solemnly publish and declare, That these United Colonies are, and of Right ought to be Free and Independent States; that they are Absolved from all Allegiance to the British Crown, and that all political connection between them and the State of Great Britain, is and ought to be totally dissolved; and that as Free and Independent States, they have full Power to levy War, conclude Peace, contract Alliances, establish Commerce, and to do all other Acts and Things which Independent States may of right do. And for the support of this Declaration, with a firm reliance on the protection of divine Providence, we mutually pledge to each other our Lives, our Fortunes and our sacred Honor.`;
|
|
1139
1955
|
//# sourceMappingURL=testArtifacts.js.map
|