@api-client/core 0.17.0 → 0.17.1
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/bin/test.ts +0 -4
- package/build/src/index.d.ts +72 -72
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +3 -3
- package/build/src/index.js.map +1 -1
- package/build/src/modeling/GraphUtils.d.ts.map +1 -1
- package/build/src/modeling/GraphUtils.js +16 -4
- package/build/src/modeling/GraphUtils.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +15 -15
- package/package.json +1 -1
- package/src/modeling/GraphUtils.ts +15 -4
- package/tests/unit/modeling/api_model.spec.ts +25 -6
- package/tests/unit/modeling/data_domain.spec.ts +47 -47
- package/tests/unit/modeling/data_domain_associations.spec.ts +41 -30
- package/tests/unit/modeling/data_domain_change_observers.spec.ts +30 -6
- package/tests/unit/modeling/data_domain_entities.spec.ts +62 -62
- package/tests/unit/modeling/data_domain_foreign.spec.ts +59 -59
- package/tests/unit/modeling/data_domain_models.spec.ts +80 -82
- package/tests/unit/modeling/data_domain_namespaces.spec.ts +76 -76
- package/tests/unit/modeling/data_domain_property.spec.ts +29 -29
- package/tests/unit/modeling/data_domain_serialization.spec.ts +9 -9
- package/tests/unit/modeling/domain_asociation_targets.spec.ts +26 -26
|
@@ -10,7 +10,7 @@ test.group('DataDomain.addEntity()', () => {
|
|
|
10
10
|
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
11
11
|
assert.instanceOf(entity, DomainEntity)
|
|
12
12
|
assert.isTrue(dataDomain.graph.hasNode(entity.key))
|
|
13
|
-
})
|
|
13
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
14
14
|
|
|
15
15
|
test('addEntity adds an entity to the graph with a parent', ({ assert }) => {
|
|
16
16
|
const dataDomain = new DataDomain()
|
|
@@ -19,14 +19,14 @@ test.group('DataDomain.addEntity()', () => {
|
|
|
19
19
|
assert.instanceOf(entity, DomainEntity)
|
|
20
20
|
assert.isTrue(dataDomain.graph.hasNode(entity.key))
|
|
21
21
|
assert.equal(dataDomain.graph.parent(entity.key), model.key)
|
|
22
|
-
})
|
|
22
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
23
23
|
|
|
24
24
|
test('addEntity throws an error if parent model does not exist', ({ assert }) => {
|
|
25
25
|
const dataDomain = new DataDomain()
|
|
26
26
|
assert.throws(() => {
|
|
27
27
|
dataDomain.addEntity('non-existent-parent', { key: 'test-entity' })
|
|
28
28
|
}, 'The parent non-existent-parent does not exist')
|
|
29
|
-
})
|
|
29
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
30
30
|
|
|
31
31
|
test('addEntity throws an error if parent is not a model', ({ assert }) => {
|
|
32
32
|
const dataDomain = new DataDomain()
|
|
@@ -34,7 +34,7 @@ test.group('DataDomain.addEntity()', () => {
|
|
|
34
34
|
assert.throws(() => {
|
|
35
35
|
dataDomain.addEntity(namespace.key, { key: 'test-entity' })
|
|
36
36
|
}, `Parent model ${namespace.key} is not a valid model`)
|
|
37
|
-
})
|
|
37
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
38
38
|
|
|
39
39
|
test('addEntity adds an entity with default values', ({ assert }) => {
|
|
40
40
|
const dataDomain = new DataDomain()
|
|
@@ -43,28 +43,28 @@ test.group('DataDomain.addEntity()', () => {
|
|
|
43
43
|
assert.instanceOf(entity, DomainEntity)
|
|
44
44
|
assert.isTrue(dataDomain.graph.hasNode(entity.key))
|
|
45
45
|
assert.equal(dataDomain.graph.parent(entity.key), model.key)
|
|
46
|
-
})
|
|
46
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
47
47
|
|
|
48
48
|
test('addEntity notifies change', async ({ assert }) => {
|
|
49
49
|
const dataDomain = new DataDomain()
|
|
50
50
|
const model = dataDomain.addModel({ key: 'test-model' })
|
|
51
51
|
dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
52
52
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
53
|
-
})
|
|
53
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
54
54
|
|
|
55
55
|
test('addEntity adds an entity to a parent model - checks parent-child relationship', ({ assert }) => {
|
|
56
56
|
const dataDomain = new DataDomain()
|
|
57
57
|
const parentModel = dataDomain.addModel({ key: 'parent-model' })
|
|
58
58
|
const entity = dataDomain.addEntity(parentModel.key, { key: 'test-entity' })
|
|
59
59
|
assert.isTrue(dataDomain.graph.hasParent(entity.key, parentModel.key))
|
|
60
|
-
})
|
|
60
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
61
61
|
|
|
62
62
|
test('addEntity adds an entity to a parent model - checks items list', ({ assert }) => {
|
|
63
63
|
const dataDomain = new DataDomain()
|
|
64
64
|
const parentModel = dataDomain.addModel({ key: 'parent-model' })
|
|
65
65
|
const entity = dataDomain.addEntity(parentModel.key, { key: 'test-entity' })
|
|
66
66
|
assert.deepInclude([...parentModel!.listEntities()], entity)
|
|
67
|
-
})
|
|
67
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
68
68
|
|
|
69
69
|
test('addEntity throws an error if no parent is provided', ({ assert }) => {
|
|
70
70
|
const dataDomain = new DataDomain()
|
|
@@ -72,7 +72,7 @@ test.group('DataDomain.addEntity()', () => {
|
|
|
72
72
|
// @ts-expect-error For testing purposes, we are passing undefined
|
|
73
73
|
dataDomain.addEntity(undefined, { key: 'test-entity' })
|
|
74
74
|
}, `An entity expects a DomainModel parent`)
|
|
75
|
-
})
|
|
75
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
76
76
|
|
|
77
77
|
test('addEntity throws when adding the same entity twice', ({ assert }) => {
|
|
78
78
|
const root = new DataDomain()
|
|
@@ -81,7 +81,7 @@ test.group('DataDomain.addEntity()', () => {
|
|
|
81
81
|
assert.throws(() => {
|
|
82
82
|
root.addEntity(m1.key, { key: 'test-entity' })
|
|
83
83
|
}, `Entity with key test-entity already exists`)
|
|
84
|
-
})
|
|
84
|
+
}).tags(['@modeling', '@entity', '@add'])
|
|
85
85
|
})
|
|
86
86
|
|
|
87
87
|
test.group('DataDomain.removeEntity()', () => {
|
|
@@ -90,14 +90,14 @@ test.group('DataDomain.removeEntity()', () => {
|
|
|
90
90
|
const entity = dataDomain.addModel({ key: 'test-model' }).addEntity({ key: 'test-entity' })
|
|
91
91
|
dataDomain.removeEntity(entity.key)
|
|
92
92
|
assert.isFalse(dataDomain.graph.hasNode(entity.key))
|
|
93
|
-
})
|
|
93
|
+
}).tags(['@modeling', '@entity', '@remove'])
|
|
94
94
|
|
|
95
95
|
test('removeEntity throws an error if entity does not exist', ({ assert }) => {
|
|
96
96
|
const dataDomain = new DataDomain()
|
|
97
97
|
assert.throws(() => {
|
|
98
98
|
dataDomain.removeEntity('non-existent-entity')
|
|
99
99
|
}, 'Entity non-existent-entity does not exist')
|
|
100
|
-
})
|
|
100
|
+
}).tags(['@modeling', '@entity', '@remove'])
|
|
101
101
|
|
|
102
102
|
test('removeEntity notifies change', async ({ assert }) => {
|
|
103
103
|
const dataDomain = new DataDomain()
|
|
@@ -105,7 +105,7 @@ test.group('DataDomain.removeEntity()', () => {
|
|
|
105
105
|
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
106
106
|
dataDomain.removeEntity(entity.key)
|
|
107
107
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
108
|
-
})
|
|
108
|
+
}).tags(['@modeling', '@entity', '@remove'])
|
|
109
109
|
|
|
110
110
|
test('removeEntity removes an entity from a parent model', ({ assert }) => {
|
|
111
111
|
const dataDomain = new DataDomain()
|
|
@@ -114,7 +114,7 @@ test.group('DataDomain.removeEntity()', () => {
|
|
|
114
114
|
dataDomain.removeEntity(entity.key)
|
|
115
115
|
assert.isFalse(dataDomain.graph.hasNode(entity.key))
|
|
116
116
|
assert.equal(dataDomain.graph.parent(entity.key), undefined)
|
|
117
|
-
})
|
|
117
|
+
}).tags(['@modeling', '@entity', '@remove'])
|
|
118
118
|
|
|
119
119
|
test('removeEntity removes an entity with properties', ({ assert }) => {
|
|
120
120
|
const dataDomain = new DataDomain()
|
|
@@ -124,7 +124,7 @@ test.group('DataDomain.removeEntity()', () => {
|
|
|
124
124
|
dataDomain.removeEntity(entity.key)
|
|
125
125
|
assert.isFalse(dataDomain.graph.hasNode(entity.key))
|
|
126
126
|
assert.isFalse(dataDomain.graph.hasNode(property.key))
|
|
127
|
-
})
|
|
127
|
+
}).tags(['@modeling', '@entity', '@remove'])
|
|
128
128
|
|
|
129
129
|
test('removeEntity removes an entity from a parent model - checks parent-child relationship', ({ assert }) => {
|
|
130
130
|
const dataDomain = new DataDomain()
|
|
@@ -132,7 +132,7 @@ test.group('DataDomain.removeEntity()', () => {
|
|
|
132
132
|
const entity = dataDomain.addEntity(parentModel.key, { key: 'test-entity' })
|
|
133
133
|
dataDomain.removeEntity(entity.key)
|
|
134
134
|
assert.isFalse(dataDomain.graph.hasParent(entity.key, parentModel.key))
|
|
135
|
-
})
|
|
135
|
+
}).tags(['@modeling', '@entity', '@remove'])
|
|
136
136
|
|
|
137
137
|
test('removeEntity removes an entity from a parent model - checks items list', ({ assert }) => {
|
|
138
138
|
const dataDomain = new DataDomain()
|
|
@@ -140,7 +140,7 @@ test.group('DataDomain.removeEntity()', () => {
|
|
|
140
140
|
const entity = dataDomain.addEntity(parentModel.key, { key: 'test-entity' })
|
|
141
141
|
dataDomain.removeEntity(entity.key)
|
|
142
142
|
assert.notDeepInclude([...parentModel!.listEntities()], entity)
|
|
143
|
-
})
|
|
143
|
+
}).tags(['@modeling', '@entity', '@remove'])
|
|
144
144
|
|
|
145
145
|
test('removeEntity throws an error if key is not an entity', ({ assert }) => {
|
|
146
146
|
const dataDomain = new DataDomain()
|
|
@@ -148,7 +148,7 @@ test.group('DataDomain.removeEntity()', () => {
|
|
|
148
148
|
assert.throws(() => {
|
|
149
149
|
dataDomain.removeEntity(model.key)
|
|
150
150
|
}, `Parent model not found for entity ${model.key}`)
|
|
151
|
-
})
|
|
151
|
+
}).tags(['@modeling', '@entity', '@remove'])
|
|
152
152
|
})
|
|
153
153
|
|
|
154
154
|
test.group('DataDomain.listEntities()', () => {
|
|
@@ -161,14 +161,14 @@ test.group('DataDomain.listEntities()', () => {
|
|
|
161
161
|
assert.lengthOf(entities, 2)
|
|
162
162
|
assert.deepInclude(entities, entity1)
|
|
163
163
|
assert.deepInclude(entities, entity2)
|
|
164
|
-
})
|
|
164
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
165
165
|
|
|
166
166
|
test('returns an empty array if there are no entities for a given parent model', ({ assert }) => {
|
|
167
167
|
const dataDomain = new DataDomain()
|
|
168
168
|
const model = dataDomain.addModel({ key: 'test-model' })
|
|
169
169
|
const entities = [...dataDomain.listEntities(model.key)]
|
|
170
170
|
assert.lengthOf(entities, 0)
|
|
171
|
-
})
|
|
171
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
172
172
|
|
|
173
173
|
test('returns only entities for a given parent model', ({ assert }) => {
|
|
174
174
|
const root = new DataDomain()
|
|
@@ -180,7 +180,7 @@ test.group('DataDomain.listEntities()', () => {
|
|
|
180
180
|
const entities = [...root.listEntities(m1.key)]
|
|
181
181
|
assert.lengthOf(entities, 1)
|
|
182
182
|
assert.deepInclude(entities, e1)
|
|
183
|
-
})
|
|
183
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
184
184
|
|
|
185
185
|
test('entities in the list are of type DomainEntity', ({ assert }) => {
|
|
186
186
|
const dataDomain = new DataDomain()
|
|
@@ -188,14 +188,14 @@ test.group('DataDomain.listEntities()', () => {
|
|
|
188
188
|
dataDomain.addEntity(model.key, { key: 'entity1' })
|
|
189
189
|
const entities = [...dataDomain.listEntities(model.key)]
|
|
190
190
|
assert.instanceOf(entities[0], DomainEntity)
|
|
191
|
-
})
|
|
191
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
192
192
|
|
|
193
193
|
test('lists entities when there are no entities', ({ assert }) => {
|
|
194
194
|
const dataDomain = new DataDomain()
|
|
195
195
|
const model = dataDomain.addModel({ key: 'test-model' })
|
|
196
196
|
const entities = [...dataDomain.listEntities(model.key)]
|
|
197
197
|
assert.deepEqual(entities, [])
|
|
198
|
-
})
|
|
198
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
199
199
|
|
|
200
200
|
test('lists entities when there are other domain elements', ({ assert }) => {
|
|
201
201
|
const dataDomain = new DataDomain()
|
|
@@ -204,20 +204,20 @@ test.group('DataDomain.listEntities()', () => {
|
|
|
204
204
|
dataDomain.addNamespace({ key: 'ns1' })
|
|
205
205
|
const entities = [...dataDomain.listEntities(model.key)]
|
|
206
206
|
assert.deepEqual(entities, [entity1])
|
|
207
|
-
})
|
|
207
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
208
208
|
|
|
209
209
|
test('returns an empty array if the parent model does not exist', ({ assert }) => {
|
|
210
210
|
const dataDomain = new DataDomain()
|
|
211
211
|
const entities = [...dataDomain.listEntities('non-existent-model')]
|
|
212
212
|
assert.deepEqual(entities, [])
|
|
213
|
-
})
|
|
213
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
214
214
|
|
|
215
215
|
test('returns an empty array if the parent is not a model', ({ assert }) => {
|
|
216
216
|
const dataDomain = new DataDomain()
|
|
217
217
|
const namespace = dataDomain.addNamespace({ key: 'test-ns' })
|
|
218
218
|
const entities = [...dataDomain.listEntities(namespace.key)]
|
|
219
219
|
assert.deepEqual(entities, [])
|
|
220
|
-
})
|
|
220
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
221
221
|
|
|
222
222
|
test('lists entities from a foreign domain', ({ assert }) => {
|
|
223
223
|
const domain1 = new DataDomain()
|
|
@@ -233,7 +233,7 @@ test.group('DataDomain.listEntities()', () => {
|
|
|
233
233
|
const children = [...domain1.listEntities(m1.key)]
|
|
234
234
|
assert.lengthOf(children, 1)
|
|
235
235
|
assert.deepInclude(children, e1)
|
|
236
|
-
})
|
|
236
|
+
}).tags(['@modeling', '@entity', '@list'])
|
|
237
237
|
})
|
|
238
238
|
|
|
239
239
|
test.group('DataDomain.findEntity()', () => {
|
|
@@ -243,75 +243,75 @@ test.group('DataDomain.findEntity()', () => {
|
|
|
243
243
|
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
244
244
|
const foundEntity = dataDomain.findEntity('test-entity')
|
|
245
245
|
assert.deepEqual(foundEntity, entity)
|
|
246
|
-
})
|
|
246
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
247
247
|
|
|
248
248
|
test('returns undefined if entity does not exist', ({ assert }) => {
|
|
249
249
|
const dataDomain = new DataDomain()
|
|
250
250
|
const foundEntity = dataDomain.findEntity('non-existent-entity')
|
|
251
251
|
assert.isUndefined(foundEntity)
|
|
252
|
-
})
|
|
252
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
253
253
|
|
|
254
254
|
test('returns undefined if key is not an entity', ({ assert }) => {
|
|
255
255
|
const dataDomain = new DataDomain()
|
|
256
256
|
const model = dataDomain.addModel({ key: 'test-model' })
|
|
257
257
|
const foundEntity = dataDomain.findEntity(model.key)
|
|
258
258
|
assert.isUndefined(foundEntity)
|
|
259
|
-
})
|
|
259
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
260
260
|
|
|
261
261
|
test('returns undefined if key is undefined', ({ assert }) => {
|
|
262
262
|
const dataDomain = new DataDomain()
|
|
263
263
|
// @ts-expect-error For testing purposes
|
|
264
264
|
const foundEntity = dataDomain.findEntity(undefined)
|
|
265
265
|
assert.isUndefined(foundEntity)
|
|
266
|
-
})
|
|
266
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
267
267
|
|
|
268
268
|
test('returns undefined if key is null', ({ assert }) => {
|
|
269
269
|
const dataDomain = new DataDomain()
|
|
270
270
|
// @ts-expect-error For testing purposes
|
|
271
271
|
const foundEntity = dataDomain.findEntity(null)
|
|
272
272
|
assert.isUndefined(foundEntity)
|
|
273
|
-
})
|
|
273
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
274
274
|
|
|
275
275
|
test('returns undefined if key is an empty string', ({ assert }) => {
|
|
276
276
|
const dataDomain = new DataDomain()
|
|
277
277
|
const foundEntity = dataDomain.findEntity('')
|
|
278
278
|
assert.isUndefined(foundEntity)
|
|
279
|
-
})
|
|
279
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
280
280
|
|
|
281
281
|
test('returns undefined if key is a number', ({ assert }) => {
|
|
282
282
|
const dataDomain = new DataDomain()
|
|
283
283
|
// @ts-expect-error For testing purposes
|
|
284
284
|
const foundEntity = dataDomain.findEntity(123)
|
|
285
285
|
assert.isUndefined(foundEntity)
|
|
286
|
-
})
|
|
286
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
287
287
|
|
|
288
288
|
test('returns undefined if key is a boolean', ({ assert }) => {
|
|
289
289
|
const dataDomain = new DataDomain()
|
|
290
290
|
// @ts-expect-error For testing purposes
|
|
291
291
|
const foundEntity = dataDomain.findEntity(true)
|
|
292
292
|
assert.isUndefined(foundEntity)
|
|
293
|
-
})
|
|
293
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
294
294
|
|
|
295
295
|
test('returns undefined if key is an object', ({ assert }) => {
|
|
296
296
|
const dataDomain = new DataDomain()
|
|
297
297
|
// @ts-expect-error For testing purposes
|
|
298
298
|
const foundEntity = dataDomain.findEntity({})
|
|
299
299
|
assert.isUndefined(foundEntity)
|
|
300
|
-
})
|
|
300
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
301
301
|
|
|
302
302
|
test('returns undefined if key is an array', ({ assert }) => {
|
|
303
303
|
const dataDomain = new DataDomain()
|
|
304
304
|
// @ts-expect-error For testing purposes
|
|
305
305
|
const foundEntity = dataDomain.findEntity([])
|
|
306
306
|
assert.isUndefined(foundEntity)
|
|
307
|
-
})
|
|
307
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
308
308
|
|
|
309
309
|
test('returns undefined if key is a function', ({ assert }) => {
|
|
310
310
|
const dataDomain = new DataDomain()
|
|
311
311
|
// @ts-expect-error For testing purposes
|
|
312
312
|
const foundEntity = dataDomain.findEntity(() => {})
|
|
313
313
|
assert.isUndefined(foundEntity)
|
|
314
|
-
})
|
|
314
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
315
315
|
|
|
316
316
|
test('finds an entity in a foreign domain', ({ assert }) => {
|
|
317
317
|
const domain1 = new DataDomain()
|
|
@@ -326,7 +326,7 @@ test.group('DataDomain.findEntity()', () => {
|
|
|
326
326
|
|
|
327
327
|
const foundEntity = domain1.findEntity('entity1')
|
|
328
328
|
assert.deepEqual(foundEntity, e1)
|
|
329
|
-
})
|
|
329
|
+
}).tags(['@modeling', '@entity', '@find'])
|
|
330
330
|
})
|
|
331
331
|
|
|
332
332
|
test.group('DomainEntity.addSemantic()', () => {
|
|
@@ -337,7 +337,7 @@ test.group('DomainEntity.addSemantic()', () => {
|
|
|
337
337
|
const semantic = { id: SemanticType.User }
|
|
338
338
|
entity.addSemantic(semantic)
|
|
339
339
|
assert.deepInclude(entity.semantics, semantic)
|
|
340
|
-
})
|
|
340
|
+
}).tags(['@modeling', '@entity', '@add', '@semantic'])
|
|
341
341
|
|
|
342
342
|
test('updates an existing semantic', ({ assert }) => {
|
|
343
343
|
const dataDomain = new DataDomain()
|
|
@@ -349,7 +349,7 @@ test.group('DomainEntity.addSemantic()', () => {
|
|
|
349
349
|
entity.addSemantic(semantic2)
|
|
350
350
|
assert.lengthOf(entity.semantics, 1)
|
|
351
351
|
assert.deepInclude(entity.semantics, semantic2)
|
|
352
|
-
})
|
|
352
|
+
}).tags(['@modeling', '@entity', '@add', '@semantic'])
|
|
353
353
|
|
|
354
354
|
test('throws an error if the semantic is not an entity semantic', ({ assert }) => {
|
|
355
355
|
const dataDomain = new DataDomain()
|
|
@@ -359,7 +359,7 @@ test.group('DomainEntity.addSemantic()', () => {
|
|
|
359
359
|
assert.throws(() => {
|
|
360
360
|
entity.addSemantic(semantic)
|
|
361
361
|
}, `Invalid semantic type: ${SemanticType.CreatedTimestamp}. Expected an entity semantic.`)
|
|
362
|
-
})
|
|
362
|
+
}).tags(['@modeling', '@entity', '@add', '@semantic'])
|
|
363
363
|
|
|
364
364
|
test('notifies change when adding a new semantic', async ({ assert }) => {
|
|
365
365
|
const dataDomain = new DataDomain()
|
|
@@ -368,7 +368,7 @@ test.group('DomainEntity.addSemantic()', () => {
|
|
|
368
368
|
const semantic = { id: SemanticType.User }
|
|
369
369
|
entity.addSemantic(semantic)
|
|
370
370
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
371
|
-
})
|
|
371
|
+
}).tags(['@modeling', '@entity', '@add', '@semantic'])
|
|
372
372
|
|
|
373
373
|
test('notifies change when updating an existing semantic', async ({ assert }) => {
|
|
374
374
|
const dataDomain = new DataDomain()
|
|
@@ -381,7 +381,7 @@ test.group('DomainEntity.addSemantic()', () => {
|
|
|
381
381
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
382
382
|
entity.addSemantic(semantic2)
|
|
383
383
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
384
|
-
})
|
|
384
|
+
}).tags(['@modeling', '@entity', '@add', '@semantic'])
|
|
385
385
|
})
|
|
386
386
|
|
|
387
387
|
test.group('DomainEntity.removeSemantic()', () => {
|
|
@@ -395,7 +395,7 @@ test.group('DomainEntity.removeSemantic()', () => {
|
|
|
395
395
|
entity.removeSemantic(SemanticType.User)
|
|
396
396
|
assert.notDeepInclude(entity.semantics, semantic)
|
|
397
397
|
assert.lengthOf(entity.semantics, 0)
|
|
398
|
-
})
|
|
398
|
+
}).tags(['@modeling', '@entity', '@remove', '@semantic'])
|
|
399
399
|
|
|
400
400
|
test('does nothing if the semantic to remove does not exist', ({ assert }) => {
|
|
401
401
|
const dataDomain = new DataDomain()
|
|
@@ -406,7 +406,7 @@ test.group('DomainEntity.removeSemantic()', () => {
|
|
|
406
406
|
const initialSemantics = [...entity.semantics]
|
|
407
407
|
entity.removeSemantic('non-existent-semantic-id' as SemanticType)
|
|
408
408
|
assert.deepEqual(entity.semantics, initialSemantics)
|
|
409
|
-
})
|
|
409
|
+
}).tags(['@modeling', '@entity', '@remove', '@semantic'])
|
|
410
410
|
|
|
411
411
|
test('notifies change when a semantic is removed', async ({ assert }) => {
|
|
412
412
|
const dataDomain = new DataDomain()
|
|
@@ -418,7 +418,7 @@ test.group('DomainEntity.removeSemantic()', () => {
|
|
|
418
418
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
419
419
|
entity.removeSemantic(SemanticType.User)
|
|
420
420
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
421
|
-
})
|
|
421
|
+
}).tags(['@modeling', '@entity', '@remove', '@semantic'])
|
|
422
422
|
|
|
423
423
|
test('does not notify change if the semantic to remove does not exist', async ({ assert }) => {
|
|
424
424
|
const dataDomain = new DataDomain()
|
|
@@ -428,7 +428,7 @@ test.group('DomainEntity.removeSemantic()', () => {
|
|
|
428
428
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
429
429
|
entity.removeSemantic('non-existent-semantic-id' as SemanticType)
|
|
430
430
|
await assert.notDispatches(dataDomain, 'change', { timeout: 20 })
|
|
431
|
-
})
|
|
431
|
+
}).tags(['@modeling', '@entity', '@remove', '@semantic'])
|
|
432
432
|
})
|
|
433
433
|
|
|
434
434
|
test.group('DomainEntity.hasSemantic()', () => {
|
|
@@ -439,21 +439,21 @@ test.group('DomainEntity.hasSemantic()', () => {
|
|
|
439
439
|
const semantic = { id: SemanticType.User }
|
|
440
440
|
entity.addSemantic(semantic)
|
|
441
441
|
assert.isTrue(entity.hasSemantic(SemanticType.User))
|
|
442
|
-
})
|
|
442
|
+
}).tags(['@modeling', '@entity', '@has', '@semantic'])
|
|
443
443
|
|
|
444
444
|
test('returns false if the entity does not have the specified semantic', ({ assert }) => {
|
|
445
445
|
const dataDomain = new DataDomain()
|
|
446
446
|
const model = dataDomain.addModel({ key: 'test-model' })
|
|
447
447
|
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
448
448
|
assert.isFalse(entity.hasSemantic(SemanticType.User))
|
|
449
|
-
})
|
|
449
|
+
}).tags(['@modeling', '@entity', '@has', '@semantic'])
|
|
450
450
|
|
|
451
451
|
test('returns false for an empty semantics array', ({ assert }) => {
|
|
452
452
|
const dataDomain = new DataDomain()
|
|
453
453
|
const model = dataDomain.addModel({ key: 'test-model' })
|
|
454
454
|
const entity = dataDomain.addEntity(model.key, { key: 'test-entity' })
|
|
455
455
|
assert.isFalse(entity.hasSemantic(SemanticType.User))
|
|
456
|
-
})
|
|
456
|
+
}).tags(['@modeling', '@entity', '@has', '@semantic'])
|
|
457
457
|
})
|
|
458
458
|
|
|
459
459
|
test.group('DataDomain.moveEntity()', () => {
|
|
@@ -466,7 +466,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
466
466
|
assert.equal(dataDomain.graph.parent(entity.key), model2.key)
|
|
467
467
|
assert.deepEqual(model1.fields, [])
|
|
468
468
|
assert.deepEqual(model2.fields, [{ key: entity.key, type: 'entity' }])
|
|
469
|
-
})
|
|
469
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
470
470
|
|
|
471
471
|
test('throws an error if the entity does not exist', ({ assert }) => {
|
|
472
472
|
const dataDomain = new DataDomain()
|
|
@@ -475,7 +475,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
475
475
|
assert.throws(() => {
|
|
476
476
|
dataDomain.moveEntity('non-existent-entity', model1.key, model2.key)
|
|
477
477
|
}, 'Entity non-existent-entity does not exist')
|
|
478
|
-
})
|
|
478
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
479
479
|
|
|
480
480
|
test('throws an error if the source model does not exist', ({ assert }) => {
|
|
481
481
|
const dataDomain = new DataDomain()
|
|
@@ -484,7 +484,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
484
484
|
assert.throws(() => {
|
|
485
485
|
dataDomain.moveEntity(entity.key, 'non-existent-model', model2.key)
|
|
486
486
|
}, 'Source model non-existent-model does not exist')
|
|
487
|
-
})
|
|
487
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
488
488
|
|
|
489
489
|
test('throws an error if the target model does not exist', ({ assert }) => {
|
|
490
490
|
const dataDomain = new DataDomain()
|
|
@@ -493,7 +493,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
493
493
|
assert.throws(() => {
|
|
494
494
|
dataDomain.moveEntity(entity.key, model1.key, 'non-existent-model')
|
|
495
495
|
}, 'Target model non-existent-model does not exist')
|
|
496
|
-
})
|
|
496
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
497
497
|
|
|
498
498
|
test('throws an error if the entity is not in the same domain', ({ assert }) => {
|
|
499
499
|
const dataDomain1 = new DataDomain()
|
|
@@ -508,7 +508,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
508
508
|
assert.throws(() => {
|
|
509
509
|
dataDomain2.moveEntity(`${dataDomain1.key}:${entity.key}`, `${dataDomain1.key}:${model1.key}`, model2.key)
|
|
510
510
|
}, 'Cannot move an entity from a foreign domain')
|
|
511
|
-
})
|
|
511
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
512
512
|
|
|
513
513
|
test('throws an error if the target model is not in the same domain', ({ assert }) => {
|
|
514
514
|
const dataDomain1 = new DataDomain()
|
|
@@ -523,7 +523,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
523
523
|
assert.throws(() => {
|
|
524
524
|
dataDomain1.moveEntity(entity.key, model1.key, `${dataDomain2.key}:${model2.key}`)
|
|
525
525
|
}, 'Cannot move an entity to a foreign domain')
|
|
526
|
-
})
|
|
526
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
527
527
|
|
|
528
528
|
test('throws an error if the source and target models are the same', ({ assert }) => {
|
|
529
529
|
const dataDomain = new DataDomain()
|
|
@@ -532,7 +532,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
532
532
|
assert.throws(() => {
|
|
533
533
|
dataDomain.moveEntity(entity.key, model1.key, model1.key)
|
|
534
534
|
}, 'Cannot move an entity to the same model')
|
|
535
|
-
})
|
|
535
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
536
536
|
|
|
537
537
|
test('throws an error if the target is not a model', ({ assert }) => {
|
|
538
538
|
const dataDomain = new DataDomain()
|
|
@@ -542,7 +542,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
542
542
|
assert.throws(() => {
|
|
543
543
|
dataDomain.moveEntity(entity.key, model1.key, namespace.key)
|
|
544
544
|
}, 'Entity or models not found in the graph')
|
|
545
|
-
})
|
|
545
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
546
546
|
|
|
547
547
|
test('notifies change', async ({ assert }) => {
|
|
548
548
|
const dataDomain = new DataDomain()
|
|
@@ -551,7 +551,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
551
551
|
const entity = model1.addEntity({ key: 'entity1' })
|
|
552
552
|
dataDomain.moveEntity(entity.key, model1.key, model2.key)
|
|
553
553
|
await assert.dispatches(dataDomain, 'change', { timeout: 20 })
|
|
554
|
-
})
|
|
554
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
555
555
|
|
|
556
556
|
test('moves an entity with properties', ({ assert }) => {
|
|
557
557
|
const dataDomain = new DataDomain()
|
|
@@ -562,7 +562,7 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
562
562
|
dataDomain.moveEntity(entity.key, model1.key, model2.key)
|
|
563
563
|
assert.equal(dataDomain.graph.parent(entity.key), model2.key)
|
|
564
564
|
assert.isTrue(dataDomain.graph.hasNode('test-property'))
|
|
565
|
-
})
|
|
565
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
566
566
|
|
|
567
567
|
test('moves an entity with associations', ({ assert }) => {
|
|
568
568
|
const dataDomain = new DataDomain()
|
|
@@ -573,5 +573,5 @@ test.group('DataDomain.moveEntity()', () => {
|
|
|
573
573
|
dataDomain.moveEntity(entity.key, model1.key, model2.key)
|
|
574
574
|
assert.equal(dataDomain.graph.parent(entity.key), model2.key)
|
|
575
575
|
assert.isTrue(dataDomain.graph.hasNode(assoc.key))
|
|
576
|
-
})
|
|
576
|
+
}).tags(['@modeling', '@entity', '@move'])
|
|
577
577
|
})
|