@api-client/core 0.14.0 → 0.14.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.
Files changed (169) hide show
  1. package/build/src/amf/AmfTypes.d.ts +1 -1
  2. package/build/src/amf/AmfTypes.js +1 -1
  3. package/build/src/amf/AmfTypes.js.map +1 -1
  4. package/build/src/amf/Utils.d.ts +0 -6
  5. package/build/src/amf/Utils.d.ts.map +1 -1
  6. package/build/src/amf/Utils.js +0 -14
  7. package/build/src/amf/Utils.js.map +1 -1
  8. package/build/src/browser.d.ts +2 -1
  9. package/build/src/browser.d.ts.map +1 -1
  10. package/build/src/browser.js +1 -0
  11. package/build/src/browser.js.map +1 -1
  12. package/build/src/index.d.ts +2 -1
  13. package/build/src/index.d.ts.map +1 -1
  14. package/build/src/index.js +1 -0
  15. package/build/src/index.js.map +1 -1
  16. package/build/src/legacy.d.ts +0 -8
  17. package/build/src/legacy.d.ts.map +1 -1
  18. package/build/src/legacy.js +0 -9
  19. package/build/src/legacy.js.map +1 -1
  20. package/build/src/modeling/Bindings.d.ts +1 -1
  21. package/build/src/modeling/Bindings.js.map +1 -1
  22. package/build/src/modeling/DataDomain.js +2 -2
  23. package/build/src/modeling/DataDomain.js.map +1 -1
  24. package/build/src/modeling/DataFormat.d.ts +0 -40
  25. package/build/src/modeling/DataFormat.d.ts.map +1 -1
  26. package/build/src/modeling/DataFormat.js +0 -27
  27. package/build/src/modeling/DataFormat.js.map +1 -1
  28. package/build/src/modeling/DomainAssociation.d.ts +63 -0
  29. package/build/src/modeling/DomainAssociation.d.ts.map +1 -1
  30. package/build/src/modeling/DomainAssociation.js +110 -4
  31. package/build/src/modeling/DomainAssociation.js.map +1 -1
  32. package/build/src/modeling/DomainEntity.d.ts +25 -9
  33. package/build/src/modeling/DomainEntity.d.ts.map +1 -1
  34. package/build/src/modeling/DomainEntity.js +65 -21
  35. package/build/src/modeling/DomainEntity.js.map +1 -1
  36. package/build/src/modeling/DomainFile.d.ts +1 -1
  37. package/build/src/modeling/DomainFile.js +1 -1
  38. package/build/src/modeling/DomainFile.js.map +1 -1
  39. package/build/src/modeling/DomainImpactAnalysis.d.ts +1 -1
  40. package/build/src/modeling/DomainImpactAnalysis.d.ts.map +1 -1
  41. package/build/src/modeling/DomainImpactAnalysis.js +3 -3
  42. package/build/src/modeling/DomainImpactAnalysis.js.map +1 -1
  43. package/build/src/modeling/DomainModel.d.ts +2 -2
  44. package/build/src/modeling/DomainModel.js +2 -2
  45. package/build/src/modeling/DomainModel.js.map +1 -1
  46. package/build/src/modeling/DomainProperty.d.ts +28 -12
  47. package/build/src/modeling/DomainProperty.d.ts.map +1 -1
  48. package/build/src/modeling/DomainProperty.js +61 -26
  49. package/build/src/modeling/DomainProperty.js.map +1 -1
  50. package/build/src/modeling/Semantics.d.ts +117 -0
  51. package/build/src/modeling/Semantics.d.ts.map +1 -0
  52. package/build/src/modeling/Semantics.js +112 -0
  53. package/build/src/modeling/Semantics.js.map +1 -0
  54. package/build/src/models/kinds.d.ts +0 -24
  55. package/build/src/models/kinds.d.ts.map +1 -1
  56. package/build/src/models/kinds.js +0 -24
  57. package/build/src/models/kinds.js.map +1 -1
  58. package/build/src/models/store/data_catalog.d.ts +1 -1
  59. package/build/src/models/store/data_catalog.js.map +1 -1
  60. package/build/tsconfig.tsbuildinfo +1 -1
  61. package/data/models/APIC-187.json +3 -3
  62. package/data/models/APIC-188.json +3 -3
  63. package/data/models/APIC-233.json +1 -1
  64. package/data/models/APIC-391.json +2 -2
  65. package/data/models/APIC-483.json +1 -1
  66. package/data/models/APIC-487.json +1 -1
  67. package/data/models/APIC-655.json +1 -1
  68. package/data/models/APIC-689.json +1 -1
  69. package/data/models/APIC-690.json +5 -5
  70. package/data/models/SE-10469.json +1 -1
  71. package/data/models/SE-13092.json +5 -5
  72. package/data/models/SE-22063.json +12 -2
  73. package/data/models/amf-helper-api.json +154 -14
  74. package/data/models/arc-demo-api.json +95 -15
  75. package/data/models/async-api.json +1 -1
  76. package/data/models/example-generator-api.json +369 -29
  77. package/data/models/expanded-api.json +1 -1
  78. package/data/models/flattened-api.json +1 -1
  79. package/data/models/multiple-servers.json +1 -1
  80. package/data/models/oas-3-api.json +1 -1
  81. package/data/models/oas-date.json +1 -1
  82. package/data/models/oas-types.json +1 -1
  83. package/data/models/oas-unions.json +1 -1
  84. package/data/models/petstore.json +1 -1
  85. package/data/models/raml-date.json +1 -1
  86. package/data/models/recursive.json +1 -1
  87. package/data/models/schema-api.json +62 -2
  88. package/data/models/secured-api.json +16 -16
  89. package/data/models/tracked-to-linked.json +4 -4
  90. package/package.json +2 -2
  91. package/src/amf/AmfTypes.ts +1 -1
  92. package/src/amf/Utils.ts +0 -15
  93. package/src/modeling/Bindings.ts +1 -1
  94. package/src/modeling/DataDomain.ts +2 -2
  95. package/src/modeling/DataFormat.ts +0 -48
  96. package/src/modeling/DomainAssociation.ts +122 -3
  97. package/src/modeling/DomainEntity.ts +56 -17
  98. package/src/modeling/DomainFile.ts +1 -1
  99. package/src/modeling/DomainImpactAnalysis.ts +3 -3
  100. package/src/modeling/DomainModel.ts +2 -2
  101. package/src/modeling/DomainProperty.ts +60 -21
  102. package/src/modeling/Semantics.ts +195 -0
  103. package/src/modeling/graph.md +14 -14
  104. package/src/modeling/readme.md +29 -29
  105. package/src/models/kinds.ts +0 -25
  106. package/src/models/store/data_catalog.ts +1 -1
  107. package/tests/unit/modeling/data_domain_change_observers.spec.ts +11 -10
  108. package/tests/unit/modeling/data_domain_entities.spec.ts +129 -1
  109. package/tests/unit/modeling/data_domain_property.spec.ts +1 -1
  110. package/tests/unit/modeling/domain_asociation.spec.ts +267 -0
  111. package/tests/unit/modeling/domain_entity.spec.ts +27 -26
  112. package/tests/unit/modeling/domain_entity_example_generator_json.spec.ts +11 -11
  113. package/tests/unit/modeling/domain_entity_example_generator_xml.spec.ts +10 -10
  114. package/tests/unit/modeling/{domain.property.spec.ts → domain_property.spec.ts} +139 -23
  115. package/tests/unit/modeling/semantics.spec.ts +149 -0
  116. package/build/src/amf/AmfShapeGenerator.d.ts +0 -103
  117. package/build/src/amf/AmfShapeGenerator.d.ts.map +0 -1
  118. package/build/src/amf/AmfShapeGenerator.js +0 -416
  119. package/build/src/amf/AmfShapeGenerator.js.map +0 -1
  120. package/build/src/modeling/legacy/DataAssociation.d.ts +0 -284
  121. package/build/src/modeling/legacy/DataAssociation.d.ts.map +0 -1
  122. package/build/src/modeling/legacy/DataAssociation.js +0 -443
  123. package/build/src/modeling/legacy/DataAssociation.js.map +0 -1
  124. package/build/src/modeling/legacy/DataEntity.d.ts +0 -358
  125. package/build/src/modeling/legacy/DataEntity.d.ts.map +0 -1
  126. package/build/src/modeling/legacy/DataEntity.js +0 -855
  127. package/build/src/modeling/legacy/DataEntity.js.map +0 -1
  128. package/build/src/modeling/legacy/DataEntityBuilder.d.ts +0 -162
  129. package/build/src/modeling/legacy/DataEntityBuilder.d.ts.map +0 -1
  130. package/build/src/modeling/legacy/DataEntityBuilder.js +0 -221
  131. package/build/src/modeling/legacy/DataEntityBuilder.js.map +0 -1
  132. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts +0 -298
  133. package/build/src/modeling/legacy/DataImpactAnalysis.d.ts.map +0 -1
  134. package/build/src/modeling/legacy/DataImpactAnalysis.js +0 -441
  135. package/build/src/modeling/legacy/DataImpactAnalysis.js.map +0 -1
  136. package/build/src/modeling/legacy/DataModel.d.ts +0 -99
  137. package/build/src/modeling/legacy/DataModel.d.ts.map +0 -1
  138. package/build/src/modeling/legacy/DataModel.js +0 -237
  139. package/build/src/modeling/legacy/DataModel.js.map +0 -1
  140. package/build/src/modeling/legacy/DataNamespace.d.ts +0 -340
  141. package/build/src/modeling/legacy/DataNamespace.d.ts.map +0 -1
  142. package/build/src/modeling/legacy/DataNamespace.js +0 -784
  143. package/build/src/modeling/legacy/DataNamespace.js.map +0 -1
  144. package/build/src/modeling/legacy/DataProperty.d.ts +0 -332
  145. package/build/src/modeling/legacy/DataProperty.d.ts.map +0 -1
  146. package/build/src/modeling/legacy/DataProperty.js +0 -415
  147. package/build/src/modeling/legacy/DataProperty.js.map +0 -1
  148. package/build/src/models/store/DataFile.d.ts +0 -29
  149. package/build/src/models/store/DataFile.d.ts.map +0 -1
  150. package/build/src/models/store/DataFile.js +0 -87
  151. package/build/src/models/store/DataFile.js.map +0 -1
  152. package/src/amf/AmfShapeGenerator.ts +0 -477
  153. package/src/modeling/legacy/DataAssociation.ts +0 -554
  154. package/src/modeling/legacy/DataEntity.ts +0 -1019
  155. package/src/modeling/legacy/DataEntityBuilder.ts +0 -236
  156. package/src/modeling/legacy/DataImpactAnalysis.ts +0 -530
  157. package/src/modeling/legacy/DataModel.ts +0 -276
  158. package/src/modeling/legacy/DataNamespace.ts +0 -929
  159. package/src/modeling/legacy/DataProperty.ts +0 -630
  160. package/src/models/store/DataFile.ts +0 -95
  161. package/tests/unit/modeling/legacy/amf_shape_generator.spec.ts +0 -1041
  162. package/tests/unit/modeling/legacy/data_association.spec.ts +0 -710
  163. package/tests/unit/modeling/legacy/data_entity.spec.ts +0 -2061
  164. package/tests/unit/modeling/legacy/data_entity_generator_json.spec.ts +0 -987
  165. package/tests/unit/modeling/legacy/data_entity_generator_xml.spec.ts +0 -1451
  166. package/tests/unit/modeling/legacy/data_model.spec.ts +0 -395
  167. package/tests/unit/modeling/legacy/data_namespace.spec.ts +0 -1312
  168. package/tests/unit/modeling/legacy/data_property.spec.ts +0 -887
  169. package/tests/unit/modeling/legacy/impact_analysis.spec.ts +0 -373
@@ -1,395 +0,0 @@
1
- import { test } from '@japa/runner'
2
- import { DataNamespace, DataModel, IDataModel, DataEntity } from '../../../../src/legacy.js'
3
- import { DataModelKind, Thing } from '../../../../src/index.js'
4
-
5
- test.group('constructor() with defaults', (group) => {
6
- let root: DataNamespace
7
- group.each.setup(() => {
8
- root = new DataNamespace()
9
- })
10
-
11
- test('sets the kind', ({ assert }) => {
12
- const assoc = new DataModel(root)
13
- assert.equal(assoc.kind, DataModelKind)
14
- })
15
-
16
- test('sets the key', ({ assert }) => {
17
- const assoc = new DataModel(root)
18
- assert.typeOf(assoc.key, 'string')
19
- assert.isNotEmpty(assoc.key)
20
- })
21
-
22
- test('sets the default "info"', ({ assert }) => {
23
- const assoc = new DataModel(root)
24
- assert.typeOf(assoc.info, 'EventTarget')
25
- assert.equal(assoc.info.name, '')
26
- })
27
-
28
- test('sets the default "entities"', ({ assert }) => {
29
- const assoc = new DataModel(root)
30
- assert.deepEqual(assoc.entities, [])
31
- })
32
- })
33
-
34
- test.group('constructor() from schema initialization', (group) => {
35
- let root: DataNamespace
36
- group.each.setup(() => {
37
- root = new DataNamespace()
38
- })
39
-
40
- test('sets the key', ({ assert }) => {
41
- const orig = new DataModel(root).toJSON()
42
- orig.key = 'test'
43
- const instance = new DataModel(root, orig)
44
- assert.equal(instance.key, 'test')
45
- })
46
-
47
- test('sets the info', ({ assert }) => {
48
- const orig = new DataModel(root).toJSON()
49
- orig.info.name = 'test'
50
- const instance = new DataModel(root, orig)
51
- assert.equal(instance.info.name, 'test')
52
- })
53
-
54
- test('initializes from JSON schema ', ({ assert }) => {
55
- const orig = new DataModel(root).toJSON()
56
- orig.key = 'test'
57
- const instance = new DataModel(root, JSON.stringify(orig))
58
- assert.equal(instance.key, 'test')
59
- })
60
- })
61
-
62
- test.group('fromName()', (group) => {
63
- let root: DataNamespace
64
- group.each.setup(() => {
65
- root = new DataNamespace()
66
- })
67
-
68
- test('sets the name', ({ assert }) => {
69
- const assoc = DataModel.fromName(root, 'test')
70
- assert.equal(assoc.info.name, 'test')
71
- })
72
- })
73
-
74
- test.group('new()', (group) => {
75
- let root: DataNamespace
76
- let base: IDataModel
77
- group.each.setup(() => {
78
- root = new DataNamespace()
79
- base = {
80
- info: Thing.fromName('test name').toJSON(),
81
- key: 'test123',
82
- kind: DataModelKind,
83
- }
84
- })
85
-
86
- test('sets the key', ({ assert }) => {
87
- const assoc = new DataModel(root)
88
- assoc.new(base)
89
- assert.equal(assoc.key, 'test123')
90
- })
91
-
92
- test('sets the info', ({ assert }) => {
93
- const assoc = new DataModel(root)
94
- assoc.new(base)
95
- assert.equal(assoc.info.name, 'test name')
96
- })
97
-
98
- test('sets default info', ({ assert }) => {
99
- const assoc = new DataModel(root)
100
- // @ts-expect-error Used in testing
101
- delete base.info
102
- assoc.new(base)
103
- assert.equal(assoc.info.name, '')
104
- })
105
-
106
- test('sets the entities as objects', ({ assert }) => {
107
- const e1 = DataEntity.fromName(root, 'e1')
108
- root.definitions.entities.push(e1)
109
- const model = new DataModel(root)
110
- base.entities = [e1.key]
111
- model.new(base)
112
- assert.deepEqual(model.entities, [e1])
113
- })
114
-
115
- test('re-sets entities when missing', ({ assert }) => {
116
- const model = new DataModel(root)
117
- model.addEntity('test')
118
- base.entities = []
119
- model.new(base)
120
- assert.deepEqual(model.entities, [])
121
- })
122
-
123
- test('throws when unknown input', ({ assert }) => {
124
- const assoc = new DataModel(root)
125
- assert.throws(() => {
126
- // @ts-expect-error Used in testing
127
- assoc.new({})
128
- }, 'Not a data model.')
129
- })
130
- })
131
-
132
- test.group('toJSON()', (group) => {
133
- let root: DataNamespace
134
- let base: DataModel
135
- group.each.setup(() => {
136
- root = new DataNamespace()
137
- base = new DataModel(root, {
138
- info: Thing.fromName('test name').toJSON(),
139
- key: 'test123',
140
- kind: DataModelKind,
141
- })
142
- })
143
-
144
- test('serializes the kind', ({ assert }) => {
145
- const result = base.toJSON()
146
- assert.equal(result.kind, DataModelKind)
147
- })
148
-
149
- test('serializes the key', ({ assert }) => {
150
- const result = base.toJSON()
151
- assert.equal(result.key, base.key)
152
- })
153
-
154
- test('serializes the info', ({ assert }) => {
155
- const result = base.toJSON()
156
- assert.equal(result.info.name, 'test name')
157
- })
158
-
159
- test('serializes the entities', ({ assert }) => {
160
- const e1 = base.addEntity('e1')
161
- const result = base.toJSON()
162
- assert.deepEqual(result.entities, [e1.key])
163
- })
164
-
165
- test('ignores entities when missing', ({ assert }) => {
166
- const result = base.toJSON()
167
- assert.isUndefined(result.entities)
168
- })
169
- })
170
-
171
- test.group('remove()', (group) => {
172
- let root: DataNamespace
173
-
174
- group.each.setup(() => {
175
- root = new DataNamespace()
176
- })
177
-
178
- test('removes self from the root definitions', ({ assert }) => {
179
- const m1 = root.addDataModel('m1')
180
- m1.remove()
181
- assert.deepEqual(root.definitions.models, [])
182
- })
183
-
184
- test('removes self only', ({ assert }) => {
185
- const m1 = root.addDataModel('m1')
186
- const m2 = root.addDataModel('m2')
187
- m1.remove()
188
- assert.deepEqual(root.definitions.models, [m2])
189
- })
190
-
191
- test('removes self a sub-namespace as parent', ({ assert }) => {
192
- const n1 = root.addNamespace('n1')
193
- const m1 = n1.addDataModel('d1')
194
- m1.remove()
195
- assert.deepEqual(n1.items, [])
196
- assert.deepEqual(root.definitions.models, [])
197
- })
198
-
199
- test('removes model entities', ({ assert }) => {
200
- const m1 = root.addDataModel('d1')
201
- m1.addEntity('e1')
202
- m1.remove()
203
- assert.deepEqual(root.definitions.entities, [])
204
- })
205
- })
206
-
207
- test.group('addEntity()', (group) => {
208
- let root: DataNamespace
209
-
210
- group.each.setup(() => {
211
- root = new DataNamespace()
212
- })
213
-
214
- test('adds an entity when the parent is root', ({ assert }) => {
215
- const m1 = root.addDataModel('m1')
216
- const e1 = m1.addEntity('e1')
217
- assert.deepEqual(root.definitions.entities, [e1])
218
- assert.deepEqual(m1.entities, [e1])
219
- })
220
-
221
- test('adds an entity when the parent is as sub-namespace', ({ assert }) => {
222
- const n1 = root.addNamespace('n1')
223
- const m1 = n1.addDataModel('m1')
224
- const e1 = m1.addEntity('e1')
225
- assert.deepEqual(root.definitions.entities, [e1])
226
- assert.deepEqual(m1.entities, [e1])
227
- })
228
- })
229
-
230
- test.group('getParentInstance()', (group) => {
231
- let root: DataNamespace
232
-
233
- group.each.setup(() => {
234
- root = new DataNamespace()
235
- })
236
-
237
- test('returns the parent as root', ({ assert }) => {
238
- const m1 = root.addDataModel('m1')
239
- const result = m1.getParentInstance()
240
- assert.isTrue(result === root)
241
- })
242
-
243
- test('returns the parent is as sub-namespace', ({ assert }) => {
244
- const n1 = root.addNamespace('n1')
245
- const m1 = n1.addDataModel('m1')
246
- const result = m1.getParentInstance()
247
- assert.isTrue(result === n1)
248
- })
249
- })
250
-
251
- test.group('breadcrumbs()', (group) => {
252
- let root: DataNamespace
253
- group.each.setup(() => {
254
- root = new DataNamespace()
255
- })
256
-
257
- test('adds root and self', ({ assert }) => {
258
- const m1 = root.addDataModel('m1')
259
- const result = m1.breadcrumbs()
260
-
261
- assert.lengthOf(result, 2, 'has the entire path')
262
- assert.equal(result[0].key, root.key, 'has the root as first')
263
- assert.equal(result[1].key, m1.key, 'has the self last')
264
- })
265
-
266
- test('adds root, sub-ns, and self', ({ assert }) => {
267
- const n1 = root.addNamespace('n1')
268
- const m1 = n1.addDataModel('m1')
269
- const result = m1.breadcrumbs()
270
- assert.lengthOf(result, 3, 'has the entire path')
271
- assert.equal(result[0].key, root.key, 'has the root as first')
272
- assert.equal(result[1].key, n1.key, 'has the child-namespace')
273
- assert.equal(result[2].key, m1.key, 'has self last')
274
- })
275
-
276
- test('adds root, sub-ns, sub-ns, and self', ({ assert }) => {
277
- const n1 = root.addNamespace('n1')
278
- const n2 = n1.addNamespace('n2')
279
- const m1 = n2.addDataModel('m1')
280
- const result = m1.breadcrumbs()
281
- assert.lengthOf(result, 4, 'has the entire path')
282
- assert.equal(result[0].key, root.key, 'has the root as first')
283
- assert.equal(result[1].key, n1.key, 'has the child-namespace')
284
- assert.equal(result[2].key, n2.key, 'has the child-namespace')
285
- assert.equal(result[3].key, m1.key, 'has self last')
286
- })
287
- })
288
-
289
- test.group('adaptEntity()', (group) => {
290
- let root: DataNamespace
291
- let dm1: DataModel
292
- let dm2: DataModel
293
- let e1: DataEntity
294
- let e2: DataEntity
295
-
296
- group.each.setup(() => {
297
- root = new DataNamespace()
298
- dm1 = root.addNamespace('dm1').addDataModel('Data Model 1')
299
- dm2 = root.addNamespace('dm2').addDataModel('Data Model 2')
300
- e1 = dm1.addEntity('Entity 1')
301
- e2 = dm1.addEntity('Entity 2')
302
- })
303
-
304
- test('moves an entity to a new data model', ({ assert }) => {
305
- dm2.adaptEntity(e1)
306
- assert.deepEqual(dm1.entities, [e2], 'removes from the old data model')
307
- assert.deepEqual(dm2.entities, [e1], 'adds to the new data model')
308
- assert.deepEqual(root.definitions.entities, [e1, e2], 'keeps the entity in the root definitions')
309
- })
310
-
311
- test('moves an entity to a new index', ({ assert }) => {
312
- const e3 = dm2.addEntity('Entity 3')
313
- dm2.adaptEntity(e1, { index: 0 })
314
- assert.deepEqual(dm1.entities, [e2], 'removes from the old data model')
315
- assert.deepEqual(dm2.entities, [e1, e3], 'adds to the new data model')
316
- assert.deepEqual(root.definitions.entities, [e1, e2, e3], 'keeps the entity in the root definitions')
317
- })
318
-
319
- test('throws when adapting an entity from another root', ({ assert }) => {
320
- const otherRoot = new DataNamespace()
321
- const otherDm = otherRoot.addNamespace('other').addDataModel('Other Data Model')
322
- const otherEntity = otherDm.addEntity('Other Entity')
323
- assert.throws(
324
- () => dm1.adaptEntity(otherEntity),
325
- `The entity ${otherEntity.key} is not in the same namespace as this data model.`
326
- )
327
- })
328
-
329
- test('throws when adapting an entity that is already adapted', ({ assert }) => {
330
- dm2.adaptEntity(e1)
331
- assert.throws(() => dm2.adaptEntity(e1), `The entity ${e1.key} is already adapted by this data model.`)
332
- })
333
-
334
- test('throws when index is out of range (minimum)', ({ assert }) => {
335
- assert.throws(() => dm2.adaptEntity(e1, { index: -1 }), `The index -1 cannot be below 0.`)
336
- })
337
-
338
- test('throws when index is out of range (maximum)', ({ assert }) => {
339
- assert.throws(() => dm2.adaptEntity(e1, { index: 1 }), `The index 1 is not valid.`)
340
- })
341
- })
342
-
343
- test.group('isChildOf()', (group) => {
344
- let root: DataNamespace
345
- let n1: DataNamespace
346
- let n2: DataNamespace
347
- let m1: DataModel
348
- let m2: DataModel
349
- let m3: DataModel
350
-
351
- group.each.setup(() => {
352
- root = new DataNamespace()
353
- n1 = root.addNamespace('n1')
354
- n2 = n1.addNamespace('n2')
355
- m1 = root.addDataModel('m1')
356
- m2 = n1.addDataModel('m2')
357
- m3 = n2.addDataModel('m3')
358
- })
359
-
360
- test('returns false when called on the root data model', ({ assert }) => {
361
- const result = m1.isChildOf('some-key')
362
- assert.isFalse(result)
363
- })
364
-
365
- test('returns true when called on a direct child', ({ assert }) => {
366
- const result = m2.isChildOf(n1.key)
367
- assert.isTrue(result)
368
- })
369
-
370
- test('returns true when called on a grandchild', ({ assert }) => {
371
- const result = m3.isChildOf(root.key)
372
- assert.isTrue(result)
373
- })
374
-
375
- test('returns false when called on a sibling', ({ assert }) => {
376
- const m4 = root.addDataModel('m4')
377
- const result = m1.isChildOf(m4.key)
378
- assert.isFalse(result)
379
- })
380
-
381
- test('returns false when called on a parent', ({ assert }) => {
382
- const result = n1.isChildOf(m2.key)
383
- assert.isFalse(result)
384
- })
385
-
386
- test('returns false when called on a non-existent namespace', ({ assert }) => {
387
- const result = m2.isChildOf('non-existent-key')
388
- assert.isFalse(result)
389
- })
390
-
391
- test('returns false when called on self', ({ assert }) => {
392
- const result = m2.isChildOf(m2.key)
393
- assert.isFalse(result)
394
- })
395
- })