@microsoft/fast-html 1.0.0-alpha.3 → 1.0.0-alpha.30

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 (58) hide show
  1. package/README.md +255 -18
  2. package/dist/dts/components/element.d.ts +10 -0
  3. package/dist/dts/components/index.d.ts +3 -1
  4. package/dist/dts/components/observer-map.d.ts +26 -0
  5. package/dist/dts/components/request-idle-callback.d.ts +41 -0
  6. package/dist/dts/components/schema.d.ts +144 -0
  7. package/dist/dts/components/template.d.ts +83 -7
  8. package/dist/dts/components/utilities.d.ts +109 -18
  9. package/dist/dts/fixtures/lifecycle-callbacks/lifecycle-callbacks.spec.d.ts +1 -0
  10. package/dist/dts/fixtures/lifecycle-callbacks/main.d.ts +5 -0
  11. package/dist/dts/fixtures/observer-map/main.d.ts +1 -0
  12. package/dist/dts/fixtures/observer-map/observer-map.spec.d.ts +1 -0
  13. package/dist/dts/index.d.ts +1 -1
  14. package/dist/esm/components/element.js +23 -0
  15. package/dist/esm/components/index.js +3 -1
  16. package/dist/esm/components/observer-map.js +53 -0
  17. package/dist/esm/components/observer-map.spec.js +19 -0
  18. package/dist/esm/components/request-idle-callback.js +72 -0
  19. package/dist/esm/components/schema.js +250 -0
  20. package/dist/esm/components/schema.spec.js +485 -0
  21. package/dist/esm/components/template.js +199 -111
  22. package/dist/esm/components/utilities.js +741 -43
  23. package/dist/esm/components/utilities.spec.js +317 -44
  24. package/dist/esm/fixtures/attribute/main.js +3 -2
  25. package/dist/esm/fixtures/binding/binding.spec.js +6 -0
  26. package/dist/esm/fixtures/binding/main.js +13 -2
  27. package/dist/esm/fixtures/children/children.spec.js +4 -0
  28. package/dist/esm/fixtures/children/main.js +3 -2
  29. package/dist/esm/fixtures/dot-syntax/dot-syntax.spec.js +109 -2
  30. package/dist/esm/fixtures/dot-syntax/main.js +30 -4
  31. package/dist/esm/fixtures/event/event.spec.js +28 -5
  32. package/dist/esm/fixtures/event/main.js +21 -5
  33. package/dist/esm/fixtures/lifecycle-callbacks/lifecycle-callbacks.spec.js +166 -0
  34. package/dist/esm/fixtures/lifecycle-callbacks/main.js +126 -0
  35. package/dist/esm/fixtures/observer-map/main.js +375 -0
  36. package/dist/esm/fixtures/observer-map/observer-map.spec.js +251 -0
  37. package/dist/esm/fixtures/ref/main.js +3 -2
  38. package/dist/esm/fixtures/ref/ref.spec.js +2 -6
  39. package/dist/esm/fixtures/repeat/main.js +27 -2
  40. package/dist/esm/fixtures/repeat/repeat.spec.js +16 -6
  41. package/dist/esm/fixtures/slotted/main.js +15 -4
  42. package/dist/esm/fixtures/slotted/slotted.spec.js +18 -19
  43. package/dist/esm/fixtures/when/main.js +139 -2
  44. package/dist/esm/fixtures/when/when.spec.js +64 -1
  45. package/dist/esm/index.js +1 -1
  46. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  47. package/dist/fast-html.api.json +333 -0
  48. package/dist/fast-html.d.ts +282 -6
  49. package/dist/fast-html.untrimmed.d.ts +282 -6
  50. package/package.json +12 -7
  51. package/rules/attribute-directives.yml +38 -0
  52. package/rules/call-expression-with-event-argument.yml +41 -0
  53. package/rules/member-expression.yml +33 -0
  54. package/rules/tag-function-to-template-literal.yml +16 -0
  55. package/dist/esm/fixtures/partial/main.js +0 -31
  56. package/dist/esm/fixtures/partial/partial.spec.js +0 -14
  57. /package/dist/dts/{fixtures/partial/main.d.ts → components/observer-map.spec.d.ts} +0 -0
  58. /package/dist/dts/{fixtures/partial/partial.spec.d.ts → components/schema.spec.d.ts} +0 -0
@@ -0,0 +1,485 @@
1
+ import { __awaiter } from "tslib";
2
+ import { expect, test } from "@playwright/test";
3
+ import { refPropertyName, Schema } from "./schema.js";
4
+ test.describe("Schema", () => __awaiter(void 0, void 0, void 0, function* () {
5
+ test("should instantiate with a custom element name without throwing", () => __awaiter(void 0, void 0, void 0, function* () {
6
+ expect(() => new Schema("my-custom-element")).not.toThrow();
7
+ }));
8
+ test("should return null when a JSON schema is requested but none exists for that property name", () => __awaiter(void 0, void 0, void 0, function* () {
9
+ const schema = new Schema("my-custom-element");
10
+ expect(schema.getSchema("foo")).toEqual(null);
11
+ }));
12
+ test("should be able to return a JSON schema after adding a path", () => __awaiter(void 0, void 0, void 0, function* () {
13
+ const schema = new Schema("my-custom-element");
14
+ schema.addPath({
15
+ rootPropertyName: "a",
16
+ pathConfig: {
17
+ type: "default",
18
+ path: "a",
19
+ currentContext: null,
20
+ parentContext: null,
21
+ },
22
+ childrenMap: null,
23
+ });
24
+ const schemaA = schema.getSchema("a");
25
+ expect(schemaA).not.toBe(null);
26
+ expect(schemaA.$id).toEqual("https://fast.design/schemas/my-custom-element/a.json");
27
+ expect(schemaA.$schema).toEqual("https://json-schema.org/draft/2019-09/schema");
28
+ }));
29
+ test("should add a property and cast the schema as type object if a nested path is given", () => __awaiter(void 0, void 0, void 0, function* () {
30
+ const schema = new Schema("my-custom-element");
31
+ schema.addPath({
32
+ rootPropertyName: "a",
33
+ pathConfig: {
34
+ type: "default",
35
+ path: "a.b",
36
+ currentContext: null,
37
+ parentContext: null,
38
+ },
39
+ childrenMap: null,
40
+ });
41
+ let schemaA = schema.getSchema("a");
42
+ expect(schemaA.properties).toBeDefined();
43
+ expect(schemaA.properties).toHaveProperty("b");
44
+ schema.addPath({
45
+ rootPropertyName: "a",
46
+ pathConfig: {
47
+ type: "default",
48
+ path: "a.b.c",
49
+ currentContext: null,
50
+ parentContext: null,
51
+ },
52
+ childrenMap: null,
53
+ });
54
+ schemaA = schema.getSchema("a");
55
+ expect(schemaA.properties).toBeDefined();
56
+ expect(schemaA.properties).toHaveProperty("b");
57
+ expect(schemaA.properties.b.properties).toBeDefined();
58
+ expect(schemaA.properties.b.properties).toHaveProperty("c");
59
+ }));
60
+ test("should add a new context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
61
+ var _a, _b, _c;
62
+ const schema = new Schema("my-custom-element");
63
+ schema.addPath({
64
+ rootPropertyName: "items",
65
+ pathConfig: {
66
+ type: "repeat",
67
+ path: "items",
68
+ currentContext: "item",
69
+ parentContext: null,
70
+ },
71
+ childrenMap: null,
72
+ });
73
+ const schemaA = schema.getSchema("items");
74
+ expect(schemaA).toBeDefined();
75
+ expect(schemaA.$ref).toBeDefined();
76
+ expect(schemaA.$ref).toEqual("#/$defs/item");
77
+ expect(schemaA.type).toEqual("array");
78
+ expect((_a = schemaA.$defs) === null || _a === void 0 ? void 0 : _a["item"]).toBeDefined();
79
+ expect((_b = schemaA.$defs) === null || _b === void 0 ? void 0 : _b["item"].$fast_context).toEqual("items");
80
+ expect((_c = schemaA.$defs) === null || _c === void 0 ? void 0 : _c["item"].$fast_parent_contexts).toEqual([null]);
81
+ }));
82
+ test("should add an object to a context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
83
+ var _d, _e, _f, _g, _h, _j;
84
+ const schema = new Schema("my-custom-element");
85
+ schema.addPath({
86
+ rootPropertyName: "items",
87
+ pathConfig: {
88
+ type: "repeat",
89
+ path: "items",
90
+ currentContext: "item",
91
+ parentContext: null,
92
+ },
93
+ childrenMap: null,
94
+ });
95
+ schema.addPath({
96
+ rootPropertyName: "items",
97
+ pathConfig: {
98
+ type: "default",
99
+ path: "item.a.b",
100
+ currentContext: "item",
101
+ parentContext: null,
102
+ },
103
+ childrenMap: null,
104
+ });
105
+ const schemaA = schema.getSchema("items");
106
+ expect(schemaA).toBeDefined();
107
+ expect(schemaA.$ref).toBeDefined();
108
+ expect(schemaA.$ref).toEqual("#/$defs/item");
109
+ expect(schemaA.type).toEqual("array");
110
+ expect((_d = schemaA.$defs) === null || _d === void 0 ? void 0 : _d["item"]).toBeDefined();
111
+ expect((_e = schemaA.$defs) === null || _e === void 0 ? void 0 : _e["item"].$fast_context).toEqual("items");
112
+ expect((_f = schemaA.$defs) === null || _f === void 0 ? void 0 : _f["item"].$fast_parent_contexts).toEqual([null]);
113
+ expect((_g = schemaA.$defs) === null || _g === void 0 ? void 0 : _g["item"].properties).toBeDefined();
114
+ expect((_h = schemaA.$defs) === null || _h === void 0 ? void 0 : _h["item"].properties["a"]).toBeDefined();
115
+ expect((_j = schemaA.$defs) === null || _j === void 0 ? void 0 : _j["item"].properties["a"].type).toEqual("object");
116
+ }));
117
+ test("should add a nested context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
118
+ var _k, _l, _m, _o, _p;
119
+ const schema = new Schema("my-custom-element");
120
+ schema.addPath({
121
+ rootPropertyName: "a",
122
+ pathConfig: {
123
+ type: "default",
124
+ path: "a",
125
+ currentContext: null,
126
+ parentContext: null,
127
+ },
128
+ childrenMap: null,
129
+ });
130
+ schema.addPath({
131
+ rootPropertyName: "a",
132
+ pathConfig: {
133
+ type: "repeat",
134
+ path: "a.items",
135
+ currentContext: "item",
136
+ parentContext: null,
137
+ },
138
+ childrenMap: null,
139
+ });
140
+ const schemaA = schema.getSchema("a");
141
+ expect(schemaA).toBeDefined();
142
+ expect((_k = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _k === void 0 ? void 0 : _k["items"]).toBeDefined();
143
+ expect((_l = schemaA === null || schemaA === void 0 ? void 0 : schemaA.properties) === null || _l === void 0 ? void 0 : _l["items"].items.$ref).toEqual("#/$defs/item");
144
+ expect((_m = schemaA.$defs) === null || _m === void 0 ? void 0 : _m["item"]).toBeDefined();
145
+ expect((_o = schemaA.$defs) === null || _o === void 0 ? void 0 : _o["item"].$fast_context).toEqual("items");
146
+ expect((_p = schemaA.$defs) === null || _p === void 0 ? void 0 : _p["item"].$fast_parent_contexts).toEqual([null]);
147
+ }));
148
+ test("should define an object as a nested context in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
149
+ var _q, _r, _s, _t, _u, _v, _w;
150
+ const schema = new Schema("my-custom-element");
151
+ schema.addPath({
152
+ rootPropertyName: "a",
153
+ pathConfig: {
154
+ type: "default",
155
+ path: "a",
156
+ currentContext: null,
157
+ parentContext: null,
158
+ },
159
+ childrenMap: null,
160
+ });
161
+ schema.addPath({
162
+ rootPropertyName: "a",
163
+ pathConfig: {
164
+ type: "repeat",
165
+ path: "a.items",
166
+ currentContext: "item",
167
+ parentContext: null,
168
+ },
169
+ childrenMap: null,
170
+ });
171
+ schema.addPath({
172
+ rootPropertyName: "a",
173
+ pathConfig: {
174
+ type: "access",
175
+ path: "item.b",
176
+ currentContext: "item",
177
+ parentContext: null,
178
+ },
179
+ childrenMap: null,
180
+ });
181
+ const schemaA = schema.getSchema("a");
182
+ expect(schemaA).toBeDefined();
183
+ expect((_q = schemaA.$defs) === null || _q === void 0 ? void 0 : _q["item"]).toBeDefined();
184
+ expect((_r = schemaA.$defs) === null || _r === void 0 ? void 0 : _r["item"].$fast_context).toEqual("items");
185
+ expect((_s = schemaA.$defs) === null || _s === void 0 ? void 0 : _s["item"].$fast_parent_contexts).toEqual([null]);
186
+ expect((_t = schemaA.$defs) === null || _t === void 0 ? void 0 : _t["item"].type).toEqual("object");
187
+ expect((_u = schemaA.$defs) === null || _u === void 0 ? void 0 : _u["item"].properties).toBeDefined();
188
+ expect((_w = (_v = schemaA.$defs) === null || _v === void 0 ? void 0 : _v["item"].properties) === null || _w === void 0 ? void 0 : _w["b"]).toBeDefined();
189
+ }));
190
+ test("should define nested contexts in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
191
+ var _x, _y, _z, _0, _1, _2;
192
+ const schema = new Schema("my-custom-element");
193
+ schema.addPath({
194
+ rootPropertyName: "a",
195
+ pathConfig: {
196
+ type: "default",
197
+ path: "a",
198
+ currentContext: null,
199
+ parentContext: null,
200
+ },
201
+ childrenMap: null,
202
+ });
203
+ schema.addPath({
204
+ rootPropertyName: "a",
205
+ pathConfig: {
206
+ type: "repeat",
207
+ path: "a.users",
208
+ currentContext: "user",
209
+ parentContext: null,
210
+ },
211
+ childrenMap: null,
212
+ });
213
+ schema.addPath({
214
+ rootPropertyName: "a",
215
+ pathConfig: {
216
+ type: "repeat",
217
+ path: "user.posts",
218
+ currentContext: "post",
219
+ parentContext: "user"
220
+ },
221
+ childrenMap: null,
222
+ });
223
+ const schemaA = schema.getSchema("a");
224
+ expect(schemaA).toBeDefined();
225
+ expect((_x = schemaA.$defs) === null || _x === void 0 ? void 0 : _x["user"]).toBeDefined();
226
+ expect((_y = schemaA.$defs) === null || _y === void 0 ? void 0 : _y["user"].$fast_context).toEqual("users");
227
+ expect((_z = schemaA.$defs) === null || _z === void 0 ? void 0 : _z["user"].$fast_parent_contexts).toEqual([null]);
228
+ expect((_0 = schemaA.$defs) === null || _0 === void 0 ? void 0 : _0["post"]).toBeDefined();
229
+ expect((_1 = schemaA.$defs) === null || _1 === void 0 ? void 0 : _1["post"].$fast_context).toEqual("posts");
230
+ expect((_2 = schemaA.$defs) === null || _2 === void 0 ? void 0 : _2["post"].$fast_parent_contexts).toEqual([null, "user"]);
231
+ }));
232
+ test("should define nested contexts with objects in a schema", () => __awaiter(void 0, void 0, void 0, function* () {
233
+ var _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23;
234
+ const schema = new Schema("my-custom-element");
235
+ schema.addPath({
236
+ rootPropertyName: "a",
237
+ pathConfig: {
238
+ type: "repeat",
239
+ path: "a.users",
240
+ currentContext: "user",
241
+ parentContext: null,
242
+ },
243
+ childrenMap: null,
244
+ });
245
+ schema.addPath({
246
+ rootPropertyName: "a",
247
+ pathConfig: {
248
+ type: "access",
249
+ path: "user.a.b",
250
+ currentContext: "user",
251
+ parentContext: null,
252
+ },
253
+ childrenMap: null,
254
+ });
255
+ schema.addPath({
256
+ rootPropertyName: "a",
257
+ pathConfig: {
258
+ type: "repeat",
259
+ path: "user.posts",
260
+ currentContext: "post",
261
+ parentContext: "user"
262
+ },
263
+ childrenMap: null,
264
+ });
265
+ schema.addPath({
266
+ rootPropertyName: "a",
267
+ pathConfig: {
268
+ type: "access",
269
+ path: "post.c.d",
270
+ currentContext: "post",
271
+ parentContext: null,
272
+ },
273
+ childrenMap: null,
274
+ });
275
+ schema.addPath({
276
+ rootPropertyName: "a",
277
+ pathConfig: {
278
+ type: "repeat",
279
+ path: "post.meta.tags",
280
+ currentContext: "tag",
281
+ parentContext: "post"
282
+ },
283
+ childrenMap: null,
284
+ });
285
+ const schemaA = schema.getSchema("a");
286
+ expect(schemaA).toBeDefined();
287
+ expect((_3 = schemaA.$defs) === null || _3 === void 0 ? void 0 : _3["user"]).toBeDefined();
288
+ expect((_4 = schemaA.$defs) === null || _4 === void 0 ? void 0 : _4["user"].$fast_context).toEqual("users");
289
+ expect((_5 = schemaA.$defs) === null || _5 === void 0 ? void 0 : _5["user"].$fast_parent_contexts).toEqual([null]);
290
+ expect((_6 = schemaA.$defs) === null || _6 === void 0 ? void 0 : _6["user"].type).toEqual("object");
291
+ expect((_7 = schemaA.$defs) === null || _7 === void 0 ? void 0 : _7["user"].properties).toBeDefined();
292
+ expect((_8 = schemaA.$defs) === null || _8 === void 0 ? void 0 : _8["user"].properties["a"]).toBeDefined();
293
+ expect((_9 = schemaA.$defs) === null || _9 === void 0 ? void 0 : _9["user"].properties["a"].properties["b"]).toBeDefined();
294
+ expect((_10 = schemaA.$defs) === null || _10 === void 0 ? void 0 : _10["post"]).toBeDefined();
295
+ expect((_11 = schemaA.$defs) === null || _11 === void 0 ? void 0 : _11["post"].$fast_context).toEqual("posts");
296
+ expect((_12 = schemaA.$defs) === null || _12 === void 0 ? void 0 : _12["post"].$fast_parent_contexts).toEqual([null, "user"]);
297
+ expect((_13 = schemaA.$defs) === null || _13 === void 0 ? void 0 : _13["post"].type).toEqual("object");
298
+ expect((_14 = schemaA.$defs) === null || _14 === void 0 ? void 0 : _14["post"].properties).toBeDefined();
299
+ expect((_15 = schemaA.$defs) === null || _15 === void 0 ? void 0 : _15["post"].properties["c"]).toBeDefined();
300
+ expect((_16 = schemaA.$defs) === null || _16 === void 0 ? void 0 : _16["post"].properties["c"].properties["d"]).toBeDefined();
301
+ expect((_17 = schemaA.$defs) === null || _17 === void 0 ? void 0 : _17["post"].properties["meta"]).toBeDefined();
302
+ expect((_18 = schemaA.$defs) === null || _18 === void 0 ? void 0 : _18["post"].properties["meta"].properties["tags"]).toBeDefined();
303
+ expect((_19 = schemaA.$defs) === null || _19 === void 0 ? void 0 : _19["post"].properties["meta"].properties["tags"].items).toBeDefined();
304
+ expect((_20 = schemaA.$defs) === null || _20 === void 0 ? void 0 : _20["post"].properties["meta"].properties["tags"].items.$ref).toEqual("#/$defs/tag");
305
+ expect((_21 = schemaA.$defs) === null || _21 === void 0 ? void 0 : _21["tag"]).toBeDefined();
306
+ expect((_22 = schemaA.$defs) === null || _22 === void 0 ? void 0 : _22["tag"].$fast_context).toEqual("tags");
307
+ expect((_23 = schemaA.$defs) === null || _23 === void 0 ? void 0 : _23["tag"].$fast_parent_contexts).toEqual([null, "user", "post"]);
308
+ }));
309
+ test("should define an anyOf with a $ref to another schema", () => __awaiter(void 0, void 0, void 0, function* () {
310
+ var _24;
311
+ const schema = new Schema("my-custom-element");
312
+ schema.addPath({
313
+ rootPropertyName: "a",
314
+ pathConfig: {
315
+ type: "default",
316
+ path: "a",
317
+ currentContext: null,
318
+ parentContext: null,
319
+ },
320
+ childrenMap: {
321
+ customElementName: "my-custom-element-2",
322
+ attributeName: "b",
323
+ },
324
+ });
325
+ const schemaA = schema.getSchema("a");
326
+ expect(schemaA).not.toBe(null);
327
+ expect(schemaA.$id).toEqual("https://fast.design/schemas/my-custom-element/a.json");
328
+ expect(schemaA.$schema).toEqual("https://json-schema.org/draft/2019-09/schema");
329
+ expect(schemaA.anyOf).not.toBeUndefined();
330
+ expect(schemaA.anyOf).toHaveLength(1);
331
+ expect((_24 = schemaA.anyOf) === null || _24 === void 0 ? void 0 : _24[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/b.json");
332
+ }));
333
+ test("should define an anyOf with a $ref to multiple schemas", () => __awaiter(void 0, void 0, void 0, function* () {
334
+ var _25, _26;
335
+ const schema = new Schema("my-custom-element");
336
+ schema.addPath({
337
+ rootPropertyName: "a",
338
+ pathConfig: {
339
+ type: "default",
340
+ path: "a",
341
+ currentContext: null,
342
+ parentContext: null,
343
+ },
344
+ childrenMap: {
345
+ customElementName: "my-custom-element-2",
346
+ attributeName: "b",
347
+ },
348
+ });
349
+ schema.addPath({
350
+ rootPropertyName: "a",
351
+ pathConfig: {
352
+ type: "default",
353
+ path: "a",
354
+ currentContext: null,
355
+ parentContext: null,
356
+ },
357
+ childrenMap: {
358
+ customElementName: "my-custom-element-3",
359
+ attributeName: "c",
360
+ },
361
+ });
362
+ const schemaA = schema.getSchema("a");
363
+ expect(schemaA).not.toBe(null);
364
+ expect(schemaA.$id).toEqual("https://fast.design/schemas/my-custom-element/a.json");
365
+ expect(schemaA.$schema).toEqual("https://json-schema.org/draft/2019-09/schema");
366
+ expect(schemaA.anyOf).not.toBeUndefined();
367
+ expect(schemaA.anyOf).toHaveLength(2);
368
+ expect((_25 = schemaA.anyOf) === null || _25 === void 0 ? void 0 : _25[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/b.json");
369
+ expect((_26 = schemaA.anyOf) === null || _26 === void 0 ? void 0 : _26[1].$ref).toEqual("https://fast.design/schemas/my-custom-element-3/c.json");
370
+ }));
371
+ test("should define an anyOf with a $ref to another schema in a nested object", () => __awaiter(void 0, void 0, void 0, function* () {
372
+ const schema = new Schema("my-custom-element");
373
+ schema.addPath({
374
+ rootPropertyName: "a",
375
+ pathConfig: {
376
+ type: "default",
377
+ path: "a.b",
378
+ currentContext: null,
379
+ parentContext: null,
380
+ },
381
+ childrenMap: null,
382
+ });
383
+ let schemaA = schema.getSchema("a");
384
+ schema.addPath({
385
+ rootPropertyName: "a",
386
+ pathConfig: {
387
+ type: "default",
388
+ path: "a.b.c",
389
+ currentContext: null,
390
+ parentContext: null,
391
+ },
392
+ childrenMap: {
393
+ customElementName: "my-custom-element-2",
394
+ attributeName: "test"
395
+ },
396
+ });
397
+ schemaA = schema.getSchema("a");
398
+ expect(schemaA.properties.b.properties.c).toBeDefined();
399
+ expect(schemaA.properties.b.properties.c.anyOf).not.toBeUndefined();
400
+ expect(schemaA.properties.b.properties.c.anyOf[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/test.json");
401
+ }));
402
+ test("should define an anyOf with a $ref to multiple schemas in a nested object", () => __awaiter(void 0, void 0, void 0, function* () {
403
+ const schema = new Schema("my-custom-element");
404
+ schema.addPath({
405
+ rootPropertyName: "a",
406
+ pathConfig: {
407
+ type: "default",
408
+ path: "a.b",
409
+ currentContext: null,
410
+ parentContext: null,
411
+ },
412
+ childrenMap: null,
413
+ });
414
+ let schemaA = schema.getSchema("a");
415
+ schema.addPath({
416
+ rootPropertyName: "a",
417
+ pathConfig: {
418
+ type: "default",
419
+ path: "a.b.c",
420
+ currentContext: null,
421
+ parentContext: null,
422
+ },
423
+ childrenMap: {
424
+ customElementName: "my-custom-element-2",
425
+ attributeName: "test"
426
+ },
427
+ });
428
+ schema.addPath({
429
+ rootPropertyName: "a",
430
+ pathConfig: {
431
+ type: "default",
432
+ path: "a.b.c",
433
+ currentContext: null,
434
+ parentContext: null,
435
+ },
436
+ childrenMap: {
437
+ customElementName: "my-custom-element-3",
438
+ attributeName: "test-2"
439
+ },
440
+ });
441
+ schemaA = schema.getSchema("a");
442
+ expect(schemaA.properties.b.properties.c).toBeDefined();
443
+ expect(schemaA.properties.b.properties.c.anyOf).not.toBeUndefined();
444
+ expect(schemaA.properties.b.properties.c.anyOf[0].$ref).toEqual("https://fast.design/schemas/my-custom-element-2/test.json");
445
+ expect(schemaA.properties.b.properties.c.anyOf[1].$ref).toEqual("https://fast.design/schemas/my-custom-element-3/test-2.json");
446
+ }));
447
+ test("should define an anyOf with a $ref in a nested object in a context", () => __awaiter(void 0, void 0, void 0, function* () {
448
+ var _27, _28, _29, _30, _31, _32, _33, _34, _35;
449
+ const schema = new Schema("my-custom-element");
450
+ schema.addPath({
451
+ rootPropertyName: "a",
452
+ pathConfig: {
453
+ type: "repeat",
454
+ path: "a.users",
455
+ currentContext: "user",
456
+ parentContext: null,
457
+ },
458
+ childrenMap: null,
459
+ });
460
+ schema.addPath({
461
+ rootPropertyName: "a",
462
+ pathConfig: {
463
+ type: "access",
464
+ path: "user.a.b",
465
+ currentContext: "user",
466
+ parentContext: null,
467
+ },
468
+ childrenMap: {
469
+ customElementName: "my-custom-element-2",
470
+ attributeName: "c"
471
+ },
472
+ });
473
+ const schemaA = schema.getSchema("a");
474
+ expect(schemaA).toBeDefined();
475
+ expect((_27 = schemaA.$defs) === null || _27 === void 0 ? void 0 : _27["user"]).toBeDefined();
476
+ expect((_28 = schemaA.$defs) === null || _28 === void 0 ? void 0 : _28["user"].$fast_context).toEqual("users");
477
+ expect((_29 = schemaA.$defs) === null || _29 === void 0 ? void 0 : _29["user"].$fast_parent_contexts).toEqual([null]);
478
+ expect((_30 = schemaA.$defs) === null || _30 === void 0 ? void 0 : _30["user"].type).toEqual("object");
479
+ expect((_31 = schemaA.$defs) === null || _31 === void 0 ? void 0 : _31["user"].properties).toBeDefined();
480
+ expect((_32 = schemaA.$defs) === null || _32 === void 0 ? void 0 : _32["user"].properties["a"]).toBeDefined();
481
+ expect((_33 = schemaA.$defs) === null || _33 === void 0 ? void 0 : _33["user"].properties["a"].properties["b"]).toBeDefined();
482
+ expect((_34 = schemaA.$defs) === null || _34 === void 0 ? void 0 : _34["user"].properties["a"].properties["b"].anyOf).toHaveLength(1);
483
+ expect((_35 = schemaA.$defs) === null || _35 === void 0 ? void 0 : _35["user"].properties["a"].properties["b"].anyOf[0][refPropertyName]).toEqual("https://fast.design/schemas/my-custom-element-2/c.json");
484
+ }));
485
+ }));