@nymphjs/server 1.0.0-beta.0 → 1.0.0-beta.2

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.
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -32,48 +23,45 @@ const nymph = new client_node_1.Nymph({
32
23
  });
33
24
  nymph.addEntityClass(testArtifacts_1.Employee);
34
25
  describe('Nymph REST Server and Client', () => {
35
- function createJane() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const jane = yield testArtifacts_1.Employee.factory();
38
- jane.name = 'Jane Doe';
39
- jane.current = true;
40
- jane.salary = 8000000;
41
- jane.startDate = Date.now();
42
- jane.subordinates = [];
43
- jane.title = 'Seniorer Person';
44
- try {
45
- yield jane.$save();
46
- }
47
- catch (e) {
48
- console.error('Error creating entity: ', e);
49
- throw e;
50
- }
51
- return jane;
52
- });
26
+ async function createJane() {
27
+ const jane = await testArtifacts_1.Employee.factory();
28
+ jane.name = 'Jane Doe';
29
+ jane.current = true;
30
+ jane.salary = 8000000;
31
+ jane.startDate = Date.now();
32
+ jane.subordinates = [];
33
+ jane.title = 'Seniorer Person';
34
+ try {
35
+ await jane.$save();
36
+ }
37
+ catch (e) {
38
+ console.error('Error creating entity: ', e);
39
+ throw e;
40
+ }
41
+ return jane;
53
42
  }
54
- it('create an entity', () => __awaiter(void 0, void 0, void 0, function* () {
55
- const jane = yield createJane();
43
+ it('create an entity', async () => {
44
+ const jane = await createJane();
56
45
  expect(jane.guid).not.toBeNull();
57
46
  expect(typeof jane.guid).toEqual('string');
58
- }));
59
- it('mdate is updated on save', () => __awaiter(void 0, void 0, void 0, function* () {
60
- var _a;
61
- const jane = yield createJane();
47
+ });
48
+ it('mdate is updated on save', async () => {
49
+ const jane = await createJane();
62
50
  expect(jane.guid).not.toBeNull();
63
- const oldMdate = (_a = jane.mdate) !== null && _a !== void 0 ? _a : Infinity;
64
- yield new Promise((resolve) => setTimeout(() => resolve(true), 100));
65
- yield jane.$save();
51
+ const oldMdate = jane.mdate ?? Infinity;
52
+ await new Promise((resolve) => setTimeout(() => resolve(true), 100));
53
+ await jane.$save();
66
54
  expect(jane.mdate).toBeGreaterThan(oldMdate);
67
- }));
68
- it('create two unrelated entities', () => __awaiter(void 0, void 0, void 0, function* () {
69
- const entity = yield testArtifacts_1.Employee.factory();
55
+ });
56
+ it('create two unrelated entities', async () => {
57
+ const entity = await testArtifacts_1.Employee.factory();
70
58
  entity.name = 'Jane Doe';
71
59
  entity.current = true;
72
60
  entity.salary = 8000000;
73
61
  entity.startDate = Date.now();
74
62
  entity.subordinates = [];
75
63
  entity.title = 'Seniorer Person';
76
- const entity2 = yield testArtifacts_1.Employee.factory();
64
+ const entity2 = await testArtifacts_1.Employee.factory();
77
65
  entity2.name = 'John Doe';
78
66
  entity2.current = true;
79
67
  entity2.salary = 8000000;
@@ -81,28 +69,28 @@ describe('Nymph REST Server and Client', () => {
81
69
  entity2.subordinates = [];
82
70
  entity2.title = 'Seniorer Person';
83
71
  const entities = [entity, entity2];
84
- yield nymph.saveEntities(entities);
72
+ await nymph.saveEntities(entities);
85
73
  if (entity.guid == null || entity2.guid == null) {
86
74
  throw new Error('Entity is null.');
87
75
  }
88
76
  entity.building = 'J2';
89
77
  entity2.building = 'B4';
90
- yield nymph.saveEntities(entities);
91
- const jane = yield nymph.getEntity({ class: testArtifacts_1.Employee }, entity.guid);
92
- const john = yield nymph.getEntity({ class: testArtifacts_1.Employee }, entity2.guid);
93
- expect(jane === null || jane === void 0 ? void 0 : jane.building).toEqual('J2');
94
- expect(john === null || john === void 0 ? void 0 : john.building).toEqual('B4');
95
- }));
96
- it('create two related entities', () => __awaiter(void 0, void 0, void 0, function* () {
97
- const jane = yield testArtifacts_1.Employee.factory();
78
+ await nymph.saveEntities(entities);
79
+ const jane = await nymph.getEntity({ class: testArtifacts_1.Employee }, entity.guid);
80
+ const john = await nymph.getEntity({ class: testArtifacts_1.Employee }, entity2.guid);
81
+ expect(jane?.building).toEqual('J2');
82
+ expect(john?.building).toEqual('B4');
83
+ });
84
+ it('create two related entities', async () => {
85
+ const jane = await testArtifacts_1.Employee.factory();
98
86
  jane.name = 'Jane Doe';
99
87
  jane.current = true;
100
88
  jane.salary = 8000000;
101
89
  jane.startDate = Date.now();
102
90
  jane.subordinates = [];
103
91
  jane.title = 'Seniorer Person';
104
- yield jane.$save();
105
- const steve = yield testArtifacts_1.Employee.factory();
92
+ await jane.$save();
93
+ const steve = await testArtifacts_1.Employee.factory();
106
94
  steve.$addTag('boss', 'bigcheese');
107
95
  steve.name = 'Steve Guy';
108
96
  steve.current = true;
@@ -110,26 +98,26 @@ describe('Nymph REST Server and Client', () => {
110
98
  steve.startDate = Date.now();
111
99
  steve.subordinates = [jane];
112
100
  steve.title = 'Executive Person';
113
- yield steve.$save();
101
+ await steve.$save();
114
102
  if (jane.guid == null || steve.guid == null) {
115
103
  throw new Error('Entity is null.');
116
104
  }
117
- const checkSteve = yield nymph.getEntity({ class: testArtifacts_1.Employee }, {
105
+ const checkSteve = await nymph.getEntity({ class: testArtifacts_1.Employee }, {
118
106
  type: '&',
119
107
  ref: ['subordinates', jane],
120
108
  });
121
- expect(checkSteve === null || checkSteve === void 0 ? void 0 : checkSteve.guid).toEqual(steve.guid);
122
- const checkSteveQref = yield nymph.getEntity({ class: testArtifacts_1.Employee }, {
109
+ expect(checkSteve?.guid).toEqual(steve.guid);
110
+ const checkSteveQref = await nymph.getEntity({ class: testArtifacts_1.Employee }, {
123
111
  type: '&',
124
112
  qref: [
125
113
  'subordinates',
126
114
  [{ class: testArtifacts_1.Employee }, { type: '&', guid: jane.guid }],
127
115
  ],
128
116
  });
129
- expect(checkSteveQref === null || checkSteveQref === void 0 ? void 0 : checkSteveQref.guid).toEqual(steve.guid);
130
- }));
131
- it('add, check, and remove tags', () => __awaiter(void 0, void 0, void 0, function* () {
132
- const entity = yield client_1.Entity.factory();
117
+ expect(checkSteveQref?.guid).toEqual(steve.guid);
118
+ });
119
+ it('add, check, and remove tags', async () => {
120
+ const entity = await client_1.Entity.factory();
133
121
  entity.$addTag('test');
134
122
  expect(entity.$hasTag('test')).toEqual(true);
135
123
  entity.$addTag('test', 'test2');
@@ -143,9 +131,9 @@ describe('Nymph REST Server and Client', () => {
143
131
  entity.$removeTag('test5', 'test6');
144
132
  expect(!entity.$hasTag('test5', 'test6')).toEqual(true);
145
133
  expect(!(entity.tags < ['test'] || entity.tags > ['test'])).toEqual(true);
146
- }));
147
- it('wake a sleeping reference', () => __awaiter(void 0, void 0, void 0, function* () {
148
- const jane = yield createJane();
134
+ });
135
+ it('wake a sleeping reference', async () => {
136
+ const jane = await createJane();
149
137
  if (jane.guid == null) {
150
138
  throw new Error('Entity is null.');
151
139
  }
@@ -154,55 +142,53 @@ describe('Nymph REST Server and Client', () => {
154
142
  jane.guid,
155
143
  'Employee',
156
144
  ]);
157
- yield entity.$ready();
158
- expect(jane === null || jane === void 0 ? void 0 : jane.name).toEqual('Jane Doe');
159
- }));
160
- it('change an entity', () => __awaiter(void 0, void 0, void 0, function* () {
161
- var _b;
162
- const employee = yield createJane();
145
+ await entity.$ready();
146
+ expect(jane?.name).toEqual('Jane Doe');
147
+ });
148
+ it('change an entity', async () => {
149
+ const employee = await createJane();
163
150
  if (employee.guid == null) {
164
151
  throw new Error('Entity is null.');
165
152
  }
166
153
  delete employee.salary;
167
154
  employee.current = false;
168
155
  employee.endDate = Date.now() + 1;
169
- yield employee.$save();
170
- const check = yield testArtifacts_1.Employee.factory(employee.guid);
156
+ await employee.$save();
157
+ const check = await testArtifacts_1.Employee.factory(employee.guid);
171
158
  expect(check.salary).toBeUndefined();
172
159
  expect(check.current).toEqual(false);
173
- expect(check.endDate).toBeGreaterThan((_b = check.startDate) !== null && _b !== void 0 ? _b : 0);
174
- }));
175
- it('patch an entity', () => __awaiter(void 0, void 0, void 0, function* () {
176
- var _c;
177
- const employee = yield createJane();
160
+ expect(check.endDate).toBeGreaterThan(check.startDate ?? 0);
161
+ });
162
+ it('patch an entity', async () => {
163
+ const employee = await createJane();
178
164
  if (employee.guid == null) {
179
165
  throw new Error('Entity is null.');
180
166
  }
181
167
  delete employee.salary;
182
168
  employee.current = false;
183
169
  employee.endDate = Date.now() + 1;
184
- yield employee.$patch();
185
- const check = yield testArtifacts_1.Employee.factory(employee.guid);
170
+ await employee.$patch();
171
+ const check = await testArtifacts_1.Employee.factory(employee.guid);
186
172
  expect(check.salary).toBeUndefined();
187
173
  expect(check.current).toEqual(false);
188
- expect(check.endDate).toBeGreaterThan((_c = check.startDate) !== null && _c !== void 0 ? _c : 0);
189
- }));
190
- it('get an entity', () => __awaiter(void 0, void 0, void 0, function* () {
191
- yield createJane();
192
- const jane = yield nymph.getEntity({
174
+ expect(check.endDate).toBeGreaterThan(check.startDate ?? 0);
175
+ });
176
+ it('get an entity', async () => {
177
+ await createJane();
178
+ const jane = await nymph.getEntity({
193
179
  class: testArtifacts_1.Employee,
194
180
  }, {
195
181
  type: '&',
196
182
  equal: ['name', 'Jane Doe'],
197
183
  });
198
184
  expect(jane).not.toBeNull();
199
- expect(jane === null || jane === void 0 ? void 0 : jane.guid).not.toBeNull();
200
- }));
201
- it('get entities', () => __awaiter(void 0, void 0, void 0, function* () {
185
+ expect(jane?.guid).not.toBeNull();
186
+ });
187
+ it('get entities', async () => {
202
188
  for (let i = 0; i < 4; i++) {
203
- yield createJane();
189
+ await createJane();
204
190
  }
205
- const entities = yield nymph.getEntities({
191
+ const entities = await nymph.getEntities({
206
192
  class: testArtifacts_1.Employee,
207
193
  limit: 4,
208
194
  }, {
@@ -213,41 +199,41 @@ describe('Nymph REST Server and Client', () => {
213
199
  entities.forEach((entity) => {
214
200
  expect(entity.guid).not.toBeNull();
215
201
  });
216
- }));
217
- it('get entity counts', () => __awaiter(void 0, void 0, void 0, function* () {
202
+ });
203
+ it('get entity counts', async () => {
218
204
  for (let i = 0; i < 20; i++) {
219
- yield createJane();
205
+ await createJane();
220
206
  }
221
- const result = yield nymph.getEntities({ class: testArtifacts_1.Employee });
222
- const resultCount = yield nymph.getEntities({
207
+ const result = await nymph.getEntities({ class: testArtifacts_1.Employee });
208
+ const resultCount = await nymph.getEntities({
223
209
  class: testArtifacts_1.Employee,
224
210
  return: 'count',
225
211
  });
226
212
  expect(resultCount).toBeGreaterThanOrEqual(1);
227
213
  expect(resultCount).toEqual(result.length);
228
- const resultSelectors = yield nymph.getEntities({ class: testArtifacts_1.Employee }, { type: '&', equal: ['name', 'Jane Doe'] });
229
- const resultSelectorsCount = yield nymph.getEntities({ class: testArtifacts_1.Employee, return: 'count' }, { type: '&', equal: ['name', 'Jane Doe'] });
214
+ const resultSelectors = await nymph.getEntities({ class: testArtifacts_1.Employee }, { type: '&', equal: ['name', 'Jane Doe'] });
215
+ const resultSelectorsCount = await nymph.getEntities({ class: testArtifacts_1.Employee, return: 'count' }, { type: '&', equal: ['name', 'Jane Doe'] });
230
216
  expect(resultSelectorsCount).toBeGreaterThanOrEqual(1);
231
217
  expect(resultSelectorsCount).toEqual(resultSelectors.length);
232
- const resultSelectorsLimit = yield nymph.getEntities({
218
+ const resultSelectorsLimit = await nymph.getEntities({
233
219
  class: testArtifacts_1.Employee,
234
220
  limit: 1,
235
221
  return: 'count',
236
222
  });
237
223
  expect(resultSelectorsLimit).toEqual(1);
238
- const resultSelectorsSingle = yield nymph.getEntity({
224
+ const resultSelectorsSingle = await nymph.getEntity({
239
225
  class: testArtifacts_1.Employee,
240
226
  return: 'count',
241
227
  });
242
228
  expect(resultSelectorsSingle).toEqual(1);
243
- const resultSelectorsEmpty = yield nymph.getEntities({ class: testArtifacts_1.Employee, return: 'count' }, { type: '&', tag: 'pickle' });
229
+ const resultSelectorsEmpty = await nymph.getEntities({ class: testArtifacts_1.Employee, return: 'count' }, { type: '&', tag: 'pickle' });
244
230
  expect(resultSelectorsEmpty).toEqual(0);
245
- }));
246
- it('get entity GUIDs', () => __awaiter(void 0, void 0, void 0, function* () {
231
+ });
232
+ it('get entity GUIDs', async () => {
247
233
  for (let i = 0; i < 4; i++) {
248
- yield createJane();
234
+ await createJane();
249
235
  }
250
- const entities = yield nymph.getEntities({
236
+ const entities = await nymph.getEntities({
251
237
  class: testArtifacts_1.Employee,
252
238
  limit: 4,
253
239
  return: 'guid',
@@ -259,12 +245,12 @@ describe('Nymph REST Server and Client', () => {
259
245
  entities.forEach((guid) => {
260
246
  expect(typeof guid).toEqual('string');
261
247
  });
262
- }));
263
- it('use two selectors', () => __awaiter(void 0, void 0, void 0, function* () {
248
+ });
249
+ it('use two selectors', async () => {
264
250
  for (let i = 0; i < 4; i++) {
265
- yield createJane();
251
+ await createJane();
266
252
  }
267
- const entities = yield nymph.getEntities({
253
+ const entities = await nymph.getEntities({
268
254
  class: testArtifacts_1.Employee,
269
255
  limit: 4,
270
256
  }, {
@@ -278,12 +264,12 @@ describe('Nymph REST Server and Client', () => {
278
264
  entities.forEach((entity) => {
279
265
  expect(entity.guid).not.toBeNull();
280
266
  });
281
- }));
282
- it('use deep selector', () => __awaiter(void 0, void 0, void 0, function* () {
267
+ });
268
+ it('use deep selector', async () => {
283
269
  for (let i = 0; i < 4; i++) {
284
- yield createJane();
270
+ await createJane();
285
271
  }
286
- const entities = yield nymph.getEntities({
272
+ const entities = await nymph.getEntities({
287
273
  class: testArtifacts_1.Employee,
288
274
  limit: 4,
289
275
  }, {
@@ -298,12 +284,12 @@ describe('Nymph REST Server and Client', () => {
298
284
  entities.forEach((entity) => {
299
285
  expect(entity.guid).not.toBeNull();
300
286
  });
301
- }));
302
- it('use really deep selector', () => __awaiter(void 0, void 0, void 0, function* () {
287
+ });
288
+ it('use really deep selector', async () => {
303
289
  for (let i = 0; i < 4; i++) {
304
- yield createJane();
290
+ await createJane();
305
291
  }
306
- const entities = yield nymph.getEntities({
292
+ const entities = await nymph.getEntities({
307
293
  class: testArtifacts_1.Employee,
308
294
  limit: 4,
309
295
  }, {
@@ -327,121 +313,121 @@ describe('Nymph REST Server and Client', () => {
327
313
  entities.forEach((entity) => {
328
314
  expect(entity.guid).not.toBeNull();
329
315
  });
330
- }));
331
- it('delete an entity', () => __awaiter(void 0, void 0, void 0, function* () {
332
- const jane = yield createJane();
316
+ });
317
+ it('delete an entity', async () => {
318
+ const jane = await createJane();
333
319
  const guid = jane.guid;
334
320
  if (guid == null) {
335
321
  throw new Error('Entity is null.');
336
322
  }
337
- const deleted = yield jane.$delete();
323
+ const deleted = await jane.$delete();
338
324
  expect(deleted).toEqual(true);
339
- const check = yield nymph.getEntities({ class: testArtifacts_1.Employee }, {
325
+ const check = await nymph.getEntities({ class: testArtifacts_1.Employee }, {
340
326
  type: '&',
341
327
  guid,
342
328
  });
343
329
  expect(check.length).toEqual(0);
344
- }));
345
- it('delete entities', () => __awaiter(void 0, void 0, void 0, function* () {
346
- const janes = [yield createJane(), yield createJane()];
330
+ });
331
+ it('delete entities', async () => {
332
+ const janes = [await createJane(), await createJane()];
347
333
  const guids = janes.map((jane) => {
348
334
  if (jane.guid == null) {
349
335
  throw new Error('Entity is null.');
350
336
  }
351
337
  return jane.guid;
352
338
  });
353
- const deleted = yield nymph.deleteEntities(janes);
339
+ const deleted = await nymph.deleteEntities(janes);
354
340
  expect(deleted).toEqual(guids);
355
- const check = yield nymph.getEntities({ class: testArtifacts_1.Employee }, {
341
+ const check = await nymph.getEntities({ class: testArtifacts_1.Employee }, {
356
342
  type: '|',
357
343
  guid: guids,
358
344
  });
359
345
  expect(check.length).toEqual(0);
360
- }));
361
- it('try to save Entity class directly', () => __awaiter(void 0, void 0, void 0, function* () {
346
+ });
347
+ it('try to save Entity class directly', async () => {
362
348
  const entity = new client_1.Entity();
363
349
  entity.$nymph = nymph;
364
350
  entity.something = 'Anything';
365
351
  let error = { message: '' };
366
352
  try {
367
- yield entity.$save();
353
+ await entity.$save();
368
354
  }
369
355
  catch (e) {
370
356
  error = e;
371
357
  }
372
358
  expect(error.message).toEqual("Can't use Entity class directly from the front end.");
373
- }));
374
- it('handle forbidden method', () => __awaiter(void 0, void 0, void 0, function* () {
359
+ });
360
+ it('handle forbidden method', async () => {
375
361
  let error = { status: 200 };
376
362
  try {
377
- yield testArtifacts_1.Employee.inaccessibleMethod();
363
+ await testArtifacts_1.Employee.inaccessibleMethod();
378
364
  }
379
365
  catch (e) {
380
366
  error = e;
381
367
  }
382
368
  expect(error.status).toEqual(403);
383
- }));
384
- it('handle server side static error', () => __awaiter(void 0, void 0, void 0, function* () {
369
+ });
370
+ it('handle server side static error', async () => {
385
371
  let error = { error: { name: '' } };
386
372
  try {
387
- yield testArtifacts_1.Employee.throwErrorStatic();
373
+ await testArtifacts_1.Employee.throwErrorStatic();
388
374
  }
389
375
  catch (e) {
390
376
  error = e;
391
377
  }
392
378
  expect(error.error.name).toEqual('BadFunctionCallError');
393
- }));
394
- it('handle server side error', () => __awaiter(void 0, void 0, void 0, function* () {
395
- const jane = yield createJane();
379
+ });
380
+ it('handle server side error', async () => {
381
+ const jane = await createJane();
396
382
  let error = { error: { name: '' } };
397
383
  try {
398
- yield jane.$throwError();
384
+ await jane.$throwError();
399
385
  }
400
386
  catch (e) {
401
387
  error = e;
402
388
  }
403
389
  expect(error.error.name).toEqual('BadFunctionCallError');
404
- }));
405
- it('call a server side static method', () => __awaiter(void 0, void 0, void 0, function* () {
406
- const data = yield testArtifacts_1.Employee.testStatic(5);
390
+ });
391
+ it('call a server side static method', async () => {
392
+ const data = await testArtifacts_1.Employee.testStatic(5);
407
393
  expect(data).toEqual(10);
408
- }));
409
- it('call a stateless server side method', () => __awaiter(void 0, void 0, void 0, function* () {
410
- const jane = yield createJane();
411
- const data = yield (jane === null || jane === void 0 ? void 0 : jane.$testMethodStateless(5));
394
+ });
395
+ it('call a stateless server side method', async () => {
396
+ const jane = await createJane();
397
+ const data = await jane?.$testMethodStateless(5);
412
398
  expect(data).toEqual(6);
413
- expect(jane === null || jane === void 0 ? void 0 : jane.name).toEqual('Jane Doe');
414
- }));
415
- it('call a server side method', () => __awaiter(void 0, void 0, void 0, function* () {
416
- const jane = yield createJane();
417
- expect(jane === null || jane === void 0 ? void 0 : jane.current).toEqual(true);
418
- const data = yield (jane === null || jane === void 0 ? void 0 : jane.$testMethod(5));
399
+ expect(jane?.name).toEqual('Jane Doe');
400
+ });
401
+ it('call a server side method', async () => {
402
+ const jane = await createJane();
403
+ expect(jane?.current).toEqual(true);
404
+ const data = await jane?.$testMethod(5);
419
405
  expect(data).toEqual(7);
420
- expect(jane === null || jane === void 0 ? void 0 : jane.current).toEqual(false);
421
- }));
422
- it('refresh an entity', () => __awaiter(void 0, void 0, void 0, function* () {
423
- const jane1 = yield createJane();
406
+ expect(jane?.current).toEqual(false);
407
+ });
408
+ it('refresh an entity', async () => {
409
+ const jane1 = await createJane();
424
410
  if (jane1.guid == null) {
425
411
  throw new Error('Entity is null.');
426
412
  }
427
- const jane2 = yield nymph.getEntity({
413
+ const jane2 = await nymph.getEntity({
428
414
  class: testArtifacts_1.Employee,
429
415
  }, jane1.guid);
430
416
  if (jane1 == null || jane2 == null) {
431
417
  throw new Error('Entity is null.');
432
418
  }
433
419
  jane1.name = 'Janet Doe';
434
- yield jane1.$save();
420
+ await jane1.$save();
435
421
  expect(jane2.name).toEqual('Jane Doe');
436
- yield jane2.$refresh();
422
+ await jane2.$refresh();
437
423
  expect(jane2.name).toEqual('Janet Doe');
438
- }));
439
- it('check two entities are equal', () => __awaiter(void 0, void 0, void 0, function* () {
440
- const first = yield createJane();
424
+ });
425
+ it('check two entities are equal', async () => {
426
+ const first = await createJane();
441
427
  if (first.guid == null) {
442
428
  throw new Error('Entity is null.');
443
429
  }
444
- const second = yield nymph.getEntity({
430
+ const second = await nymph.getEntity({
445
431
  class: testArtifacts_1.Employee,
446
432
  }, first.guid);
447
433
  if (second == null || second.guid == null) {
@@ -455,13 +441,13 @@ describe('Nymph REST Server and Client', () => {
455
441
  second.other = 'that';
456
442
  second.thing = 'that';
457
443
  expect(first.$equals(second)).toEqual(false);
458
- }));
459
- it('check two objects are the same entity', () => __awaiter(void 0, void 0, void 0, function* () {
460
- const first = yield createJane();
444
+ });
445
+ it('check two objects are the same entity', async () => {
446
+ const first = await createJane();
461
447
  if (first.guid == null) {
462
448
  throw new Error('Entity is null.');
463
449
  }
464
- const second = yield nymph.getEntity({
450
+ const second = await nymph.getEntity({
465
451
  class: testArtifacts_1.Employee,
466
452
  }, first.guid);
467
453
  if (second == null || second.guid == null) {
@@ -471,8 +457,8 @@ describe('Nymph REST Server and Client', () => {
471
457
  second.other = 'this';
472
458
  second.thing = 'this';
473
459
  expect(first.$is(second)).toEqual(true);
474
- yield createJane();
475
- const third = yield nymph.getEntity({
460
+ await createJane();
461
+ const third = await nymph.getEntity({
476
462
  class: testArtifacts_1.Employee,
477
463
  }, {
478
464
  type: '&',
@@ -482,47 +468,47 @@ describe('Nymph REST Server and Client', () => {
482
468
  throw new Error('Entity is null.');
483
469
  }
484
470
  expect(first.$is(third)).toEqual(false);
485
- }));
486
- it('get a new UID', () => __awaiter(void 0, void 0, void 0, function* () {
487
- const uidValue = yield nymph.newUID('employee');
471
+ });
472
+ it('get a new UID', async () => {
473
+ const uidValue = await nymph.newUID('employee');
488
474
  expect(typeof uidValue).toEqual('number');
489
475
  expect(uidValue).toBeGreaterThan(0);
490
- const uidValue2 = yield nymph.newUID('employee');
476
+ const uidValue2 = await nymph.newUID('employee');
491
477
  expect(typeof uidValue2).toEqual('number');
492
478
  expect(uidValue2).toBeGreaterThan(uidValue);
493
- }));
494
- it('get UID value', () => __awaiter(void 0, void 0, void 0, function* () {
495
- const uidValue = yield nymph.getUID('employee');
479
+ });
480
+ it('get UID value', async () => {
481
+ const uidValue = await nymph.getUID('employee');
496
482
  expect(typeof uidValue).toEqual('number');
497
483
  expect(uidValue).toBeGreaterThan(0);
498
- const uidValue2 = yield nymph.getUID('employee');
484
+ const uidValue2 = await nymph.getUID('employee');
499
485
  expect(typeof uidValue2).toEqual('number');
500
486
  expect(uidValue2).toEqual(uidValue);
501
- }));
502
- it('set UID value', () => __awaiter(void 0, void 0, void 0, function* () {
503
- const uidValue = yield nymph.newUID('employee');
487
+ });
488
+ it('set UID value', async () => {
489
+ const uidValue = await nymph.newUID('employee');
504
490
  expect(typeof uidValue).toEqual('number');
505
491
  expect(uidValue).toBeGreaterThan(0);
506
- const success = yield nymph.setUID('employee', uidValue - 1);
492
+ const success = await nymph.setUID('employee', uidValue - 1);
507
493
  expect(success).toEqual(true);
508
- const uidValue2 = yield nymph.getUID('employee');
494
+ const uidValue2 = await nymph.getUID('employee');
509
495
  expect(typeof uidValue2).toEqual('number');
510
496
  expect(uidValue2).toEqual(uidValue - 1);
511
- }));
512
- it('delete UID', () => __awaiter(void 0, void 0, void 0, function* () {
513
- const uidValue = yield nymph.newUID('temp');
497
+ });
498
+ it('delete UID', async () => {
499
+ const uidValue = await nymph.newUID('temp');
514
500
  expect(typeof uidValue).toEqual('number');
515
501
  expect(uidValue).toEqual(1);
516
- yield nymph.deleteUID('temp');
502
+ await nymph.deleteUID('temp');
517
503
  let error = { status: 200 };
518
504
  try {
519
- yield nymph.getUID('temp');
505
+ await nymph.getUID('temp');
520
506
  }
521
507
  catch (e) {
522
508
  error = e;
523
509
  }
524
510
  expect(error.status).toEqual(404);
525
- }));
511
+ });
526
512
  afterAll(() => {
527
513
  server.close();
528
514
  });