@player-ui/player 0.8.0--canary.307.9621 → 0.8.0-next.0
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/dist/Player.native.js +11630 -0
- package/dist/Player.native.js.map +1 -0
- package/dist/cjs/index.cjs +5626 -0
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/{index.esm.js → index.legacy-esm.js} +2044 -1667
- package/dist/{index.cjs.js → index.mjs} +2052 -1761
- package/dist/index.mjs.map +1 -0
- package/package.json +29 -63
- package/src/__tests__/data.test.ts +498 -0
- package/src/__tests__/flow.test.ts +312 -0
- package/src/__tests__/helpers/action-exp.plugin.ts +22 -0
- package/src/__tests__/helpers/actions.flow.ts +67 -0
- package/src/__tests__/helpers/binding.plugin.ts +125 -0
- package/src/__tests__/helpers/expression.plugin.ts +88 -0
- package/src/__tests__/helpers/transform-plugin.ts +19 -0
- package/src/__tests__/helpers/validation.flow.ts +56 -0
- package/src/__tests__/player.test.ts +597 -0
- package/src/__tests__/string-resolver.test.ts +186 -0
- package/src/__tests__/validation.test.ts +3555 -0
- package/src/__tests__/view.test.ts +715 -0
- package/src/binding/__tests__/binding.test.ts +113 -0
- package/src/binding/__tests__/index.test.ts +208 -0
- package/src/binding/__tests__/resolver.test.ts +83 -0
- package/src/binding/binding.ts +6 -6
- package/src/binding/index.ts +34 -34
- package/src/binding/resolver.ts +19 -19
- package/src/binding/utils.ts +7 -7
- package/src/binding-grammar/__tests__/parser.test.ts +64 -0
- package/src/binding-grammar/__tests__/test-utils/ast-cases.ts +198 -0
- package/src/binding-grammar/__tests__/test-utils/perf-test.ts +66 -0
- package/src/binding-grammar/ast.ts +11 -11
- package/src/binding-grammar/custom/index.ts +19 -22
- package/src/binding-grammar/ebnf/index.ts +20 -21
- package/src/binding-grammar/ebnf/types.ts +13 -13
- package/src/binding-grammar/index.ts +4 -4
- package/src/binding-grammar/parsimmon/index.ts +14 -14
- package/src/controllers/constants/__tests__/index.test.ts +106 -0
- package/src/controllers/constants/index.ts +3 -3
- package/src/controllers/constants/utils.ts +4 -4
- package/src/controllers/data/controller.ts +22 -22
- package/src/controllers/data/index.ts +1 -1
- package/src/controllers/data/utils.ts +7 -7
- package/src/controllers/flow/__tests__/controller.test.ts +195 -0
- package/src/controllers/flow/__tests__/flow.test.ts +381 -0
- package/src/controllers/flow/controller.ts +13 -13
- package/src/controllers/flow/flow.ts +23 -23
- package/src/controllers/flow/index.ts +2 -2
- package/src/controllers/index.ts +5 -5
- package/src/controllers/validation/binding-tracker.ts +71 -59
- package/src/controllers/validation/controller.ts +104 -104
- package/src/controllers/validation/index.ts +2 -2
- package/src/controllers/view/asset-transform.ts +20 -20
- package/src/controllers/view/controller.ts +27 -27
- package/src/controllers/view/index.ts +4 -4
- package/src/controllers/view/store.ts +3 -3
- package/src/controllers/view/types.ts +7 -7
- package/src/data/__tests__/__snapshots__/dependency-tracker.test.ts.snap +64 -0
- package/src/data/__tests__/dependency-tracker.test.ts +146 -0
- package/src/data/__tests__/local-model.test.ts +46 -0
- package/src/data/__tests__/model.test.ts +78 -0
- package/src/data/dependency-tracker.ts +16 -16
- package/src/data/index.ts +4 -4
- package/src/data/local-model.ts +6 -6
- package/src/data/model.ts +17 -17
- package/src/data/noop-model.ts +1 -1
- package/src/expressions/__tests__/__snapshots__/parser.test.ts.snap +854 -0
- package/src/expressions/__tests__/evaluator-functions.test.ts +47 -0
- package/src/expressions/__tests__/evaluator.test.ts +410 -0
- package/src/expressions/__tests__/parser.test.ts +115 -0
- package/src/expressions/__tests__/utils.test.ts +44 -0
- package/src/expressions/evaluator-functions.ts +6 -6
- package/src/expressions/evaluator.ts +71 -67
- package/src/expressions/index.ts +4 -4
- package/src/expressions/parser.ts +102 -105
- package/src/expressions/types.ts +29 -21
- package/src/expressions/utils.ts +32 -21
- package/src/index.ts +13 -13
- package/src/logger/__tests__/consoleLogger.test.ts +46 -0
- package/src/logger/__tests__/noopLogger.test.ts +13 -0
- package/src/logger/__tests__/proxyLogger.test.ts +31 -0
- package/src/logger/__tests__/tapableLogger.test.ts +41 -0
- package/src/logger/consoleLogger.ts +9 -9
- package/src/logger/index.ts +5 -5
- package/src/logger/noopLogger.ts +1 -1
- package/src/logger/proxyLogger.ts +6 -6
- package/src/logger/tapableLogger.ts +7 -7
- package/src/logger/types.ts +2 -2
- package/src/player.ts +60 -58
- package/src/plugins/default-exp-plugin.ts +10 -10
- package/src/plugins/default-view-plugin.ts +29 -0
- package/src/plugins/flow-exp-plugin.ts +6 -6
- package/src/schema/__tests__/schema.test.ts +243 -0
- package/src/schema/index.ts +2 -2
- package/src/schema/schema.ts +24 -24
- package/src/schema/types.ts +4 -4
- package/src/string-resolver/__tests__/index.test.ts +361 -0
- package/src/string-resolver/index.ts +17 -17
- package/src/types.ts +17 -17
- package/src/utils/__tests__/replaceParams.test.ts +33 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/replaceParams.ts +1 -1
- package/src/validator/__tests__/binding-map-splice.test.ts +53 -0
- package/src/validator/__tests__/validation-middleware.test.ts +127 -0
- package/src/validator/binding-map-splice.ts +5 -5
- package/src/validator/index.ts +4 -4
- package/src/validator/registry.ts +1 -1
- package/src/validator/types.ts +13 -13
- package/src/validator/validation-middleware.ts +15 -15
- package/src/view/__tests__/view.immutable.test.ts +269 -0
- package/src/view/__tests__/view.test.ts +959 -0
- package/src/view/builder/index.test.ts +69 -0
- package/src/view/builder/index.ts +3 -3
- package/src/view/index.ts +5 -5
- package/src/view/parser/__tests__/__snapshots__/parser.test.ts.snap +394 -0
- package/src/view/parser/__tests__/parser.test.ts +264 -0
- package/src/view/parser/index.ts +43 -33
- package/src/view/parser/types.ts +11 -11
- package/src/view/parser/utils.ts +5 -5
- package/src/view/plugins/__tests__/__snapshots__/template.test.ts.snap +278 -0
- package/src/view/plugins/__tests__/applicability.test.ts +265 -0
- package/src/view/plugins/__tests__/string.test.ts +122 -0
- package/src/view/plugins/__tests__/template.test.ts +724 -0
- package/src/view/plugins/applicability.ts +19 -19
- package/src/view/plugins/index.ts +4 -5
- package/src/view/plugins/options.ts +1 -1
- package/src/view/plugins/string-resolver.ts +22 -22
- package/src/view/plugins/switch.ts +22 -23
- package/src/view/plugins/template-plugin.ts +26 -27
- package/src/view/resolver/__tests__/dependencies.test.ts +321 -0
- package/src/view/resolver/__tests__/edgecases.test.ts +626 -0
- package/src/view/resolver/index.ts +42 -42
- package/src/view/resolver/types.ts +21 -20
- package/src/view/resolver/utils.ts +9 -9
- package/src/view/view.ts +32 -22
- package/types/binding/binding.d.ts +50 -0
- package/types/binding/index.d.ts +29 -0
- package/types/binding/resolver.d.ts +26 -0
- package/types/binding/utils.d.ts +12 -0
- package/types/binding-grammar/ast.d.ts +67 -0
- package/types/binding-grammar/custom/index.d.ts +4 -0
- package/types/binding-grammar/ebnf/index.d.ts +4 -0
- package/types/binding-grammar/ebnf/types.d.ts +75 -0
- package/types/binding-grammar/index.d.ts +5 -0
- package/types/binding-grammar/parsimmon/index.d.ts +4 -0
- package/types/controllers/constants/index.d.ts +45 -0
- package/types/controllers/constants/utils.d.ts +6 -0
- package/types/controllers/data/controller.d.ts +45 -0
- package/types/controllers/data/index.d.ts +2 -0
- package/types/controllers/data/utils.d.ts +14 -0
- package/types/controllers/flow/controller.d.ts +25 -0
- package/types/controllers/flow/flow.d.ts +50 -0
- package/types/controllers/flow/index.d.ts +3 -0
- package/types/controllers/index.d.ts +6 -0
- package/types/controllers/validation/binding-tracker.d.ts +32 -0
- package/types/controllers/validation/controller.d.ts +151 -0
- package/types/controllers/validation/index.d.ts +3 -0
- package/types/controllers/view/asset-transform.d.ts +19 -0
- package/types/controllers/view/controller.d.ts +37 -0
- package/types/controllers/view/index.d.ts +5 -0
- package/types/controllers/view/store.d.ts +20 -0
- package/types/controllers/view/types.d.ts +16 -0
- package/types/data/dependency-tracker.d.ts +49 -0
- package/types/data/index.d.ts +5 -0
- package/types/data/local-model.d.ts +16 -0
- package/types/data/model.d.ts +86 -0
- package/types/data/noop-model.d.ts +13 -0
- package/types/expressions/evaluator-functions.d.ts +15 -0
- package/types/expressions/evaluator.d.ts +52 -0
- package/types/expressions/index.d.ts +5 -0
- package/types/expressions/parser.d.ts +10 -0
- package/types/expressions/types.d.ts +144 -0
- package/types/expressions/utils.d.ts +12 -0
- package/types/index.d.ts +14 -0
- package/types/logger/consoleLogger.d.ts +17 -0
- package/types/logger/index.d.ts +6 -0
- package/types/logger/noopLogger.d.ts +10 -0
- package/types/logger/proxyLogger.d.ts +15 -0
- package/types/logger/tapableLogger.d.ts +23 -0
- package/types/logger/types.d.ts +6 -0
- package/types/player.d.ts +101 -0
- package/types/plugins/default-exp-plugin.d.ts +9 -0
- package/types/plugins/default-view-plugin.d.ts +9 -0
- package/types/plugins/flow-exp-plugin.d.ts +11 -0
- package/types/schema/index.d.ts +3 -0
- package/types/schema/schema.d.ts +36 -0
- package/types/schema/types.d.ts +38 -0
- package/types/string-resolver/index.d.ts +30 -0
- package/types/types.d.ts +73 -0
- package/types/utils/index.d.ts +2 -0
- package/types/utils/replaceParams.d.ts +9 -0
- package/types/validator/binding-map-splice.d.ts +10 -0
- package/types/validator/index.d.ts +5 -0
- package/types/validator/registry.d.ts +11 -0
- package/types/validator/types.d.ts +53 -0
- package/types/validator/validation-middleware.d.ts +36 -0
- package/types/view/builder/index.d.ts +35 -0
- package/types/view/index.d.ts +6 -0
- package/types/view/parser/index.d.ts +52 -0
- package/types/view/parser/types.d.ts +109 -0
- package/types/view/parser/utils.d.ts +6 -0
- package/types/view/plugins/applicability.d.ts +10 -0
- package/types/view/plugins/index.d.ts +5 -0
- package/types/view/plugins/options.d.ts +4 -0
- package/types/view/plugins/string-resolver.d.ts +13 -0
- package/types/view/plugins/switch.d.ts +14 -0
- package/types/view/plugins/template-plugin.d.ts +33 -0
- package/types/view/resolver/index.d.ts +73 -0
- package/types/view/resolver/types.d.ts +129 -0
- package/types/view/resolver/utils.d.ts +11 -0
- package/types/view/view.d.ts +37 -0
- package/dist/index.d.ts +0 -1814
- package/dist/player.dev.js +0 -11472
- package/dist/player.prod.js +0 -2
- package/src/view/plugins/plugin.ts +0 -21
|
@@ -0,0 +1,959 @@
|
|
|
1
|
+
import { describe, it, expect, test } from "vitest";
|
|
2
|
+
import { LocalModel, withParser } from "../../data";
|
|
3
|
+
import { ExpressionEvaluator } from "../../expressions";
|
|
4
|
+
import { BindingParser } from "../../binding";
|
|
5
|
+
import { SchemaController } from "../../schema";
|
|
6
|
+
import {
|
|
7
|
+
StringResolverPlugin,
|
|
8
|
+
SwitchPlugin,
|
|
9
|
+
ViewInstance,
|
|
10
|
+
toNodeResolveOptions,
|
|
11
|
+
} from "..";
|
|
12
|
+
|
|
13
|
+
const parseBinding = new BindingParser().parse;
|
|
14
|
+
|
|
15
|
+
describe("view", () => {
|
|
16
|
+
describe("switch", () => {
|
|
17
|
+
it("works on a static switch", () => {
|
|
18
|
+
const model = withParser(
|
|
19
|
+
new LocalModel({
|
|
20
|
+
foo: {
|
|
21
|
+
bar: true,
|
|
22
|
+
baz: false,
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
parseBinding,
|
|
26
|
+
);
|
|
27
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
28
|
+
const schema = new SchemaController();
|
|
29
|
+
|
|
30
|
+
const view = new ViewInstance(
|
|
31
|
+
{
|
|
32
|
+
id: "foo",
|
|
33
|
+
fields: {
|
|
34
|
+
staticSwitch: [
|
|
35
|
+
{
|
|
36
|
+
case: "{{foo.baz}}",
|
|
37
|
+
asset: {
|
|
38
|
+
id: "input-1",
|
|
39
|
+
type: "input",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
case: "{{foo.bar}}",
|
|
44
|
+
asset: {
|
|
45
|
+
id: "input-2",
|
|
46
|
+
type: "input",
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
} as any,
|
|
52
|
+
{
|
|
53
|
+
model,
|
|
54
|
+
parseBinding,
|
|
55
|
+
evaluator,
|
|
56
|
+
schema,
|
|
57
|
+
},
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
61
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
62
|
+
new StringResolverPlugin().apply(view);
|
|
63
|
+
|
|
64
|
+
const resolved = view.update();
|
|
65
|
+
|
|
66
|
+
expect(resolved).toStrictEqual({
|
|
67
|
+
id: "foo",
|
|
68
|
+
fields: {
|
|
69
|
+
asset: {
|
|
70
|
+
id: "input-2",
|
|
71
|
+
type: "input",
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const bazBinding = parseBinding("foo.baz");
|
|
77
|
+
model.set([[bazBinding, true]]);
|
|
78
|
+
|
|
79
|
+
const updated = view.update(new Set([bazBinding]));
|
|
80
|
+
expect(updated).toBe(resolved);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test("works with no valid switch cases in an array", () => {
|
|
84
|
+
const model = withParser(new LocalModel({}), parseBinding);
|
|
85
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
86
|
+
const schema = new SchemaController();
|
|
87
|
+
|
|
88
|
+
const view = new ViewInstance(
|
|
89
|
+
{
|
|
90
|
+
id: "test",
|
|
91
|
+
type: "view",
|
|
92
|
+
title: [
|
|
93
|
+
{
|
|
94
|
+
staticSwitch: [
|
|
95
|
+
{
|
|
96
|
+
case: false,
|
|
97
|
+
asset: {
|
|
98
|
+
id: "false-case",
|
|
99
|
+
type: "text",
|
|
100
|
+
value: "some text",
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
case: false,
|
|
105
|
+
asset: {
|
|
106
|
+
id: "false-case-2",
|
|
107
|
+
type: "text",
|
|
108
|
+
value: "some text",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
model,
|
|
117
|
+
parseBinding,
|
|
118
|
+
evaluator,
|
|
119
|
+
schema,
|
|
120
|
+
},
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
124
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
125
|
+
new StringResolverPlugin().apply(view);
|
|
126
|
+
|
|
127
|
+
const resolved = view.update();
|
|
128
|
+
|
|
129
|
+
expect(resolved).toStrictEqual({
|
|
130
|
+
id: "test",
|
|
131
|
+
type: "view",
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it("does not return a field object if the case does not resolve an asset", () => {
|
|
136
|
+
const model = withParser(
|
|
137
|
+
new LocalModel({
|
|
138
|
+
foo: {
|
|
139
|
+
bar: true,
|
|
140
|
+
baz: false,
|
|
141
|
+
},
|
|
142
|
+
}),
|
|
143
|
+
parseBinding,
|
|
144
|
+
);
|
|
145
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
146
|
+
const schema = new SchemaController();
|
|
147
|
+
|
|
148
|
+
const view = new ViewInstance(
|
|
149
|
+
{
|
|
150
|
+
id: "foo",
|
|
151
|
+
fields: {
|
|
152
|
+
staticSwitch: [
|
|
153
|
+
{
|
|
154
|
+
case: "{{foo.baz}}",
|
|
155
|
+
asset: {
|
|
156
|
+
id: "input-1",
|
|
157
|
+
type: "input",
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
case: "{{foo.bar}}",
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
},
|
|
165
|
+
} as any,
|
|
166
|
+
{
|
|
167
|
+
model,
|
|
168
|
+
parseBinding,
|
|
169
|
+
evaluator,
|
|
170
|
+
schema,
|
|
171
|
+
},
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
175
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
176
|
+
new StringResolverPlugin().apply(view);
|
|
177
|
+
|
|
178
|
+
const resolved = view.update();
|
|
179
|
+
|
|
180
|
+
expect(resolved).toStrictEqual({
|
|
181
|
+
id: "foo",
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
const bazBinding = parseBinding("foo.baz");
|
|
185
|
+
model.set([[bazBinding, true]]);
|
|
186
|
+
|
|
187
|
+
const updated = view.update(new Set([bazBinding]));
|
|
188
|
+
expect(updated).toBe(resolved);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
it("works with default case", () => {
|
|
192
|
+
const model = withParser(
|
|
193
|
+
new LocalModel({
|
|
194
|
+
foo: {
|
|
195
|
+
baz: "bad",
|
|
196
|
+
},
|
|
197
|
+
}),
|
|
198
|
+
parseBinding,
|
|
199
|
+
);
|
|
200
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
201
|
+
const schema = new SchemaController();
|
|
202
|
+
|
|
203
|
+
const view = new ViewInstance(
|
|
204
|
+
{
|
|
205
|
+
id: "foo",
|
|
206
|
+
fields: {
|
|
207
|
+
staticSwitch: [
|
|
208
|
+
{
|
|
209
|
+
case: '{{foo.baz}} === "good"',
|
|
210
|
+
asset: {
|
|
211
|
+
id: "input-1",
|
|
212
|
+
type: "input",
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
case: true,
|
|
217
|
+
asset: {
|
|
218
|
+
id: "input-2",
|
|
219
|
+
type: "input",
|
|
220
|
+
},
|
|
221
|
+
},
|
|
222
|
+
],
|
|
223
|
+
},
|
|
224
|
+
} as any,
|
|
225
|
+
{
|
|
226
|
+
model,
|
|
227
|
+
parseBinding,
|
|
228
|
+
evaluator,
|
|
229
|
+
schema,
|
|
230
|
+
},
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
234
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
235
|
+
new StringResolverPlugin().apply(view);
|
|
236
|
+
|
|
237
|
+
const resolved = view.update();
|
|
238
|
+
|
|
239
|
+
expect(resolved).toStrictEqual({
|
|
240
|
+
id: "foo",
|
|
241
|
+
fields: {
|
|
242
|
+
asset: {
|
|
243
|
+
id: "input-2",
|
|
244
|
+
type: "input",
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
it("works on a dynamic switch", () => {
|
|
251
|
+
const model = withParser(
|
|
252
|
+
new LocalModel({
|
|
253
|
+
foo: {
|
|
254
|
+
bar: true,
|
|
255
|
+
baz: false,
|
|
256
|
+
},
|
|
257
|
+
}),
|
|
258
|
+
parseBinding,
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
262
|
+
const schema = new SchemaController();
|
|
263
|
+
|
|
264
|
+
const view = new ViewInstance(
|
|
265
|
+
{
|
|
266
|
+
id: "foo",
|
|
267
|
+
fields: {
|
|
268
|
+
dynamicSwitch: [
|
|
269
|
+
{
|
|
270
|
+
case: "{{foo.baz}}",
|
|
271
|
+
asset: {
|
|
272
|
+
id: "input-1",
|
|
273
|
+
type: "input",
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
case: "{{foo.bar}}",
|
|
278
|
+
asset: {
|
|
279
|
+
id: "input-2",
|
|
280
|
+
type: "input",
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
],
|
|
284
|
+
},
|
|
285
|
+
} as any,
|
|
286
|
+
{
|
|
287
|
+
schema,
|
|
288
|
+
model,
|
|
289
|
+
parseBinding,
|
|
290
|
+
evaluator,
|
|
291
|
+
},
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
295
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
296
|
+
new StringResolverPlugin().apply(view);
|
|
297
|
+
|
|
298
|
+
const resolved = view.update();
|
|
299
|
+
|
|
300
|
+
expect(resolved).toStrictEqual({
|
|
301
|
+
id: "foo",
|
|
302
|
+
fields: {
|
|
303
|
+
asset: {
|
|
304
|
+
id: "input-2",
|
|
305
|
+
type: "input",
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const bazBinding = parseBinding("foo.baz");
|
|
311
|
+
model.set([[bazBinding, true]]);
|
|
312
|
+
|
|
313
|
+
const updated = view.update(new Set([bazBinding]));
|
|
314
|
+
expect(updated).toStrictEqual({
|
|
315
|
+
id: "foo",
|
|
316
|
+
fields: {
|
|
317
|
+
asset: {
|
|
318
|
+
id: "input-1",
|
|
319
|
+
type: "input",
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it("dynamic - works inside of an array", () => {
|
|
326
|
+
const model = withParser(
|
|
327
|
+
new LocalModel({
|
|
328
|
+
foo: {
|
|
329
|
+
baz: "bad",
|
|
330
|
+
},
|
|
331
|
+
}),
|
|
332
|
+
parseBinding,
|
|
333
|
+
);
|
|
334
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
335
|
+
const schema = new SchemaController();
|
|
336
|
+
|
|
337
|
+
const view = new ViewInstance(
|
|
338
|
+
{
|
|
339
|
+
id: "foo",
|
|
340
|
+
fields: {
|
|
341
|
+
asset: {
|
|
342
|
+
type: "collection",
|
|
343
|
+
id: "collection",
|
|
344
|
+
values: [
|
|
345
|
+
{
|
|
346
|
+
dynamicSwitch: [
|
|
347
|
+
{
|
|
348
|
+
case: '{{foo.baz}} === "good"',
|
|
349
|
+
asset: {
|
|
350
|
+
id: "input-1",
|
|
351
|
+
type: "input",
|
|
352
|
+
},
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
case: '{{foo.baz}} === "bad"',
|
|
356
|
+
asset: {
|
|
357
|
+
id: "input-2",
|
|
358
|
+
type: "input",
|
|
359
|
+
},
|
|
360
|
+
},
|
|
361
|
+
],
|
|
362
|
+
},
|
|
363
|
+
{
|
|
364
|
+
asset: {
|
|
365
|
+
id: "other-asset",
|
|
366
|
+
type: "text",
|
|
367
|
+
value: "other value",
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
},
|
|
372
|
+
},
|
|
373
|
+
} as any,
|
|
374
|
+
{
|
|
375
|
+
model,
|
|
376
|
+
parseBinding,
|
|
377
|
+
evaluator,
|
|
378
|
+
schema,
|
|
379
|
+
},
|
|
380
|
+
);
|
|
381
|
+
|
|
382
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
383
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
384
|
+
new StringResolverPlugin().apply(view);
|
|
385
|
+
|
|
386
|
+
const resolved = view.update();
|
|
387
|
+
|
|
388
|
+
expect(resolved).toStrictEqual({
|
|
389
|
+
id: "foo",
|
|
390
|
+
fields: {
|
|
391
|
+
asset: {
|
|
392
|
+
id: "collection",
|
|
393
|
+
type: "collection",
|
|
394
|
+
values: [
|
|
395
|
+
{
|
|
396
|
+
asset: {
|
|
397
|
+
id: "input-2",
|
|
398
|
+
type: "input",
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
{
|
|
402
|
+
asset: {
|
|
403
|
+
id: "other-asset",
|
|
404
|
+
type: "text",
|
|
405
|
+
value: "other value",
|
|
406
|
+
},
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
},
|
|
410
|
+
},
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
const bazBinding = parseBinding("foo.baz");
|
|
414
|
+
model.set([[bazBinding, true]]);
|
|
415
|
+
|
|
416
|
+
const updated = view.update(new Set([bazBinding]));
|
|
417
|
+
expect(updated).toStrictEqual({
|
|
418
|
+
id: "foo",
|
|
419
|
+
fields: {
|
|
420
|
+
asset: {
|
|
421
|
+
id: "collection",
|
|
422
|
+
type: "collection",
|
|
423
|
+
values: [
|
|
424
|
+
{
|
|
425
|
+
asset: {
|
|
426
|
+
id: "other-asset",
|
|
427
|
+
type: "text",
|
|
428
|
+
value: "other value",
|
|
429
|
+
},
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
});
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it("static - works inside of an array", () => {
|
|
438
|
+
const model = withParser(new LocalModel({}), parseBinding);
|
|
439
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
440
|
+
const schema = new SchemaController();
|
|
441
|
+
|
|
442
|
+
const view = new ViewInstance(
|
|
443
|
+
{
|
|
444
|
+
id: "test",
|
|
445
|
+
type: "view",
|
|
446
|
+
|
|
447
|
+
title: {
|
|
448
|
+
staticSwitch: [
|
|
449
|
+
{
|
|
450
|
+
case: false,
|
|
451
|
+
asset: {
|
|
452
|
+
id: "false-case",
|
|
453
|
+
type: "text",
|
|
454
|
+
value: "some text",
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
{
|
|
458
|
+
case: false,
|
|
459
|
+
asset: {
|
|
460
|
+
id: "false-case-2",
|
|
461
|
+
type: "text",
|
|
462
|
+
value: "some text",
|
|
463
|
+
},
|
|
464
|
+
},
|
|
465
|
+
],
|
|
466
|
+
},
|
|
467
|
+
} as any,
|
|
468
|
+
|
|
469
|
+
{
|
|
470
|
+
model,
|
|
471
|
+
parseBinding,
|
|
472
|
+
evaluator,
|
|
473
|
+
schema,
|
|
474
|
+
},
|
|
475
|
+
);
|
|
476
|
+
|
|
477
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
478
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
479
|
+
new StringResolverPlugin().apply(view);
|
|
480
|
+
|
|
481
|
+
const resolved = view.update();
|
|
482
|
+
|
|
483
|
+
expect(resolved).toStrictEqual({
|
|
484
|
+
id: "test",
|
|
485
|
+
type: "view",
|
|
486
|
+
});
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
it("does not return a field object if the case does not resolve an asset", () => {
|
|
490
|
+
const model = withParser(
|
|
491
|
+
new LocalModel({
|
|
492
|
+
foo: {
|
|
493
|
+
bar: true,
|
|
494
|
+
baz: false,
|
|
495
|
+
},
|
|
496
|
+
}),
|
|
497
|
+
parseBinding,
|
|
498
|
+
);
|
|
499
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
500
|
+
const schema = new SchemaController();
|
|
501
|
+
|
|
502
|
+
const view = new ViewInstance(
|
|
503
|
+
{
|
|
504
|
+
id: "foo",
|
|
505
|
+
fields: {
|
|
506
|
+
staticSwitch: [
|
|
507
|
+
{
|
|
508
|
+
case: "{{foo.baz}}",
|
|
509
|
+
asset: {
|
|
510
|
+
id: "input-1",
|
|
511
|
+
type: "input",
|
|
512
|
+
},
|
|
513
|
+
},
|
|
514
|
+
{
|
|
515
|
+
case: "{{foo.bar}}",
|
|
516
|
+
},
|
|
517
|
+
],
|
|
518
|
+
},
|
|
519
|
+
} as any,
|
|
520
|
+
{
|
|
521
|
+
model,
|
|
522
|
+
parseBinding,
|
|
523
|
+
evaluator,
|
|
524
|
+
schema,
|
|
525
|
+
},
|
|
526
|
+
);
|
|
527
|
+
|
|
528
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
529
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
530
|
+
new StringResolverPlugin().apply(view);
|
|
531
|
+
|
|
532
|
+
const resolved = view.update();
|
|
533
|
+
|
|
534
|
+
expect(resolved).toStrictEqual({
|
|
535
|
+
id: "foo",
|
|
536
|
+
});
|
|
537
|
+
|
|
538
|
+
const bazBinding = parseBinding("foo.baz");
|
|
539
|
+
model.set([[bazBinding, true]]);
|
|
540
|
+
|
|
541
|
+
const updated = view.update(new Set([bazBinding]));
|
|
542
|
+
expect(updated).toBe(resolved);
|
|
543
|
+
});
|
|
544
|
+
|
|
545
|
+
it("works with default case", () => {
|
|
546
|
+
const model = withParser(
|
|
547
|
+
new LocalModel({
|
|
548
|
+
foo: {
|
|
549
|
+
baz: "bad",
|
|
550
|
+
},
|
|
551
|
+
}),
|
|
552
|
+
parseBinding,
|
|
553
|
+
);
|
|
554
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
555
|
+
const schema = new SchemaController();
|
|
556
|
+
|
|
557
|
+
const view = new ViewInstance(
|
|
558
|
+
{
|
|
559
|
+
id: "foo",
|
|
560
|
+
fields: {
|
|
561
|
+
staticSwitch: [
|
|
562
|
+
{
|
|
563
|
+
case: "{{foo.baz}} === 'good'",
|
|
564
|
+
asset: {
|
|
565
|
+
id: "input-1",
|
|
566
|
+
type: "input",
|
|
567
|
+
},
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
case: true,
|
|
571
|
+
asset: {
|
|
572
|
+
id: "input-2",
|
|
573
|
+
type: "input",
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
],
|
|
577
|
+
},
|
|
578
|
+
} as any,
|
|
579
|
+
{
|
|
580
|
+
model,
|
|
581
|
+
parseBinding,
|
|
582
|
+
evaluator,
|
|
583
|
+
schema,
|
|
584
|
+
},
|
|
585
|
+
);
|
|
586
|
+
|
|
587
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
588
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
589
|
+
new StringResolverPlugin().apply(view);
|
|
590
|
+
|
|
591
|
+
const resolved = view.update();
|
|
592
|
+
|
|
593
|
+
expect(resolved).toStrictEqual({
|
|
594
|
+
id: "foo",
|
|
595
|
+
fields: {
|
|
596
|
+
asset: {
|
|
597
|
+
id: "input-2",
|
|
598
|
+
type: "input",
|
|
599
|
+
},
|
|
600
|
+
},
|
|
601
|
+
});
|
|
602
|
+
});
|
|
603
|
+
|
|
604
|
+
it("works on a dynamic switch", () => {
|
|
605
|
+
const model = withParser(
|
|
606
|
+
new LocalModel({
|
|
607
|
+
foo: {
|
|
608
|
+
bar: true,
|
|
609
|
+
baz: false,
|
|
610
|
+
},
|
|
611
|
+
}),
|
|
612
|
+
parseBinding,
|
|
613
|
+
);
|
|
614
|
+
|
|
615
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
616
|
+
const schema = new SchemaController();
|
|
617
|
+
|
|
618
|
+
const view = new ViewInstance(
|
|
619
|
+
{
|
|
620
|
+
id: "foo",
|
|
621
|
+
fields: {
|
|
622
|
+
dynamicSwitch: [
|
|
623
|
+
{
|
|
624
|
+
case: "{{foo.baz}}",
|
|
625
|
+
asset: {
|
|
626
|
+
id: "input-1",
|
|
627
|
+
type: "input",
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
case: "{{foo.bar}}",
|
|
632
|
+
asset: {
|
|
633
|
+
id: "input-2",
|
|
634
|
+
type: "input",
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
],
|
|
638
|
+
},
|
|
639
|
+
} as any,
|
|
640
|
+
{
|
|
641
|
+
schema,
|
|
642
|
+
model,
|
|
643
|
+
parseBinding,
|
|
644
|
+
evaluator,
|
|
645
|
+
},
|
|
646
|
+
);
|
|
647
|
+
|
|
648
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
649
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
650
|
+
new StringResolverPlugin().apply(view);
|
|
651
|
+
|
|
652
|
+
const resolved = view.update();
|
|
653
|
+
|
|
654
|
+
expect(resolved).toStrictEqual({
|
|
655
|
+
id: "foo",
|
|
656
|
+
fields: {
|
|
657
|
+
asset: {
|
|
658
|
+
id: "input-2",
|
|
659
|
+
type: "input",
|
|
660
|
+
},
|
|
661
|
+
},
|
|
662
|
+
});
|
|
663
|
+
|
|
664
|
+
const bazBinding = parseBinding("foo.baz");
|
|
665
|
+
model.set([[bazBinding, true]]);
|
|
666
|
+
|
|
667
|
+
const updated = view.update(new Set([bazBinding]));
|
|
668
|
+
expect(updated).toStrictEqual({
|
|
669
|
+
id: "foo",
|
|
670
|
+
fields: {
|
|
671
|
+
asset: {
|
|
672
|
+
id: "input-1",
|
|
673
|
+
type: "input",
|
|
674
|
+
},
|
|
675
|
+
},
|
|
676
|
+
});
|
|
677
|
+
});
|
|
678
|
+
|
|
679
|
+
it("dynamic - works inside of an array", () => {
|
|
680
|
+
const model = withParser(
|
|
681
|
+
new LocalModel({
|
|
682
|
+
foo: {
|
|
683
|
+
baz: "bad",
|
|
684
|
+
},
|
|
685
|
+
}),
|
|
686
|
+
parseBinding,
|
|
687
|
+
);
|
|
688
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
689
|
+
const schema = new SchemaController();
|
|
690
|
+
|
|
691
|
+
const view = new ViewInstance(
|
|
692
|
+
{
|
|
693
|
+
id: "foo",
|
|
694
|
+
fields: {
|
|
695
|
+
asset: {
|
|
696
|
+
type: "collection",
|
|
697
|
+
id: "collection",
|
|
698
|
+
values: [
|
|
699
|
+
{
|
|
700
|
+
dynamicSwitch: [
|
|
701
|
+
{
|
|
702
|
+
case: "{{foo.baz}} === 'good'",
|
|
703
|
+
asset: {
|
|
704
|
+
id: "input-1",
|
|
705
|
+
type: "input",
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
{
|
|
709
|
+
case: "{{foo.baz}} === 'bad'",
|
|
710
|
+
asset: {
|
|
711
|
+
id: "input-2",
|
|
712
|
+
type: "input",
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
],
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
asset: {
|
|
719
|
+
id: "other-asset",
|
|
720
|
+
type: "text",
|
|
721
|
+
value: "other value",
|
|
722
|
+
},
|
|
723
|
+
},
|
|
724
|
+
],
|
|
725
|
+
},
|
|
726
|
+
},
|
|
727
|
+
} as any,
|
|
728
|
+
{
|
|
729
|
+
model,
|
|
730
|
+
parseBinding,
|
|
731
|
+
evaluator,
|
|
732
|
+
schema,
|
|
733
|
+
},
|
|
734
|
+
);
|
|
735
|
+
|
|
736
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
737
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
738
|
+
new StringResolverPlugin().apply(view);
|
|
739
|
+
|
|
740
|
+
const resolved = view.update();
|
|
741
|
+
|
|
742
|
+
expect(resolved).toStrictEqual({
|
|
743
|
+
id: "foo",
|
|
744
|
+
fields: {
|
|
745
|
+
asset: {
|
|
746
|
+
id: "collection",
|
|
747
|
+
type: "collection",
|
|
748
|
+
values: [
|
|
749
|
+
{
|
|
750
|
+
asset: {
|
|
751
|
+
id: "input-2",
|
|
752
|
+
type: "input",
|
|
753
|
+
},
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
asset: {
|
|
757
|
+
id: "other-asset",
|
|
758
|
+
type: "text",
|
|
759
|
+
value: "other value",
|
|
760
|
+
},
|
|
761
|
+
},
|
|
762
|
+
],
|
|
763
|
+
},
|
|
764
|
+
},
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
const bazBinding = parseBinding("foo.baz");
|
|
768
|
+
model.set([[bazBinding, true]]);
|
|
769
|
+
|
|
770
|
+
const updated = view.update(new Set([bazBinding]));
|
|
771
|
+
expect(updated).toStrictEqual({
|
|
772
|
+
id: "foo",
|
|
773
|
+
fields: {
|
|
774
|
+
asset: {
|
|
775
|
+
id: "collection",
|
|
776
|
+
type: "collection",
|
|
777
|
+
values: [
|
|
778
|
+
{
|
|
779
|
+
asset: {
|
|
780
|
+
id: "other-asset",
|
|
781
|
+
type: "text",
|
|
782
|
+
value: "other value",
|
|
783
|
+
},
|
|
784
|
+
},
|
|
785
|
+
],
|
|
786
|
+
},
|
|
787
|
+
},
|
|
788
|
+
});
|
|
789
|
+
});
|
|
790
|
+
|
|
791
|
+
it("static - works inside of an array", () => {
|
|
792
|
+
const model = withParser(new LocalModel({}), parseBinding);
|
|
793
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
794
|
+
const schema = new SchemaController();
|
|
795
|
+
|
|
796
|
+
const view = new ViewInstance(
|
|
797
|
+
{
|
|
798
|
+
id: "foo",
|
|
799
|
+
fields: {
|
|
800
|
+
asset: {
|
|
801
|
+
type: "collection",
|
|
802
|
+
id: "collection",
|
|
803
|
+
values: [
|
|
804
|
+
{
|
|
805
|
+
staticSwitch: [
|
|
806
|
+
{
|
|
807
|
+
case: true,
|
|
808
|
+
asset: {
|
|
809
|
+
id: "input-2",
|
|
810
|
+
type: "input",
|
|
811
|
+
},
|
|
812
|
+
},
|
|
813
|
+
],
|
|
814
|
+
},
|
|
815
|
+
{
|
|
816
|
+
asset: {
|
|
817
|
+
id: "other-asset",
|
|
818
|
+
type: "text",
|
|
819
|
+
value: "other value",
|
|
820
|
+
},
|
|
821
|
+
},
|
|
822
|
+
],
|
|
823
|
+
},
|
|
824
|
+
},
|
|
825
|
+
} as any,
|
|
826
|
+
{
|
|
827
|
+
model,
|
|
828
|
+
parseBinding,
|
|
829
|
+
evaluator,
|
|
830
|
+
schema,
|
|
831
|
+
},
|
|
832
|
+
);
|
|
833
|
+
|
|
834
|
+
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
835
|
+
new SwitchPlugin(pluginOptions).apply(view);
|
|
836
|
+
new StringResolverPlugin().apply(view);
|
|
837
|
+
|
|
838
|
+
const resolved = view.update();
|
|
839
|
+
|
|
840
|
+
expect(resolved).toStrictEqual({
|
|
841
|
+
id: "foo",
|
|
842
|
+
fields: {
|
|
843
|
+
asset: {
|
|
844
|
+
id: "collection",
|
|
845
|
+
type: "collection",
|
|
846
|
+
values: [
|
|
847
|
+
{
|
|
848
|
+
asset: {
|
|
849
|
+
id: "input-2",
|
|
850
|
+
type: "input",
|
|
851
|
+
},
|
|
852
|
+
},
|
|
853
|
+
{
|
|
854
|
+
asset: {
|
|
855
|
+
id: "other-asset",
|
|
856
|
+
type: "text",
|
|
857
|
+
value: "other value",
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
],
|
|
861
|
+
},
|
|
862
|
+
},
|
|
863
|
+
});
|
|
864
|
+
});
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
describe("string-updates", () => {
|
|
868
|
+
it("works on expressions", () => {
|
|
869
|
+
const model = withParser(
|
|
870
|
+
new LocalModel({
|
|
871
|
+
foo: {
|
|
872
|
+
hello: "Hello",
|
|
873
|
+
world: "World",
|
|
874
|
+
},
|
|
875
|
+
}),
|
|
876
|
+
parseBinding,
|
|
877
|
+
);
|
|
878
|
+
const schema = new SchemaController();
|
|
879
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
880
|
+
|
|
881
|
+
const view = new ViewInstance(
|
|
882
|
+
{
|
|
883
|
+
id: "foo",
|
|
884
|
+
fields: {
|
|
885
|
+
asset: {
|
|
886
|
+
id: "test",
|
|
887
|
+
type: "text",
|
|
888
|
+
value: "Before @[ {{foo.hello}} + ' ' + {{foo.world}} ]@ After",
|
|
889
|
+
},
|
|
890
|
+
},
|
|
891
|
+
} as any,
|
|
892
|
+
{
|
|
893
|
+
model,
|
|
894
|
+
parseBinding,
|
|
895
|
+
evaluator,
|
|
896
|
+
schema,
|
|
897
|
+
},
|
|
898
|
+
);
|
|
899
|
+
|
|
900
|
+
new StringResolverPlugin().apply(view);
|
|
901
|
+
|
|
902
|
+
const resolved = view.update();
|
|
903
|
+
|
|
904
|
+
expect(resolved).toStrictEqual({
|
|
905
|
+
id: "foo",
|
|
906
|
+
fields: {
|
|
907
|
+
asset: {
|
|
908
|
+
id: "test",
|
|
909
|
+
type: "text",
|
|
910
|
+
value: "Before Hello World After",
|
|
911
|
+
},
|
|
912
|
+
},
|
|
913
|
+
});
|
|
914
|
+
|
|
915
|
+
const worldBinding = parseBinding("foo.world");
|
|
916
|
+
model.set([[worldBinding, "Adam"]]);
|
|
917
|
+
|
|
918
|
+
const updated = view.update(new Set([worldBinding]));
|
|
919
|
+
expect(updated).toStrictEqual({
|
|
920
|
+
id: "foo",
|
|
921
|
+
fields: {
|
|
922
|
+
asset: {
|
|
923
|
+
id: "test",
|
|
924
|
+
type: "text",
|
|
925
|
+
value: "Before Hello Adam After",
|
|
926
|
+
},
|
|
927
|
+
},
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
model.set([[parseBinding("foo.unrelated"), "other stuff"]]);
|
|
931
|
+
expect(view.update(new Set([parseBinding("foo.unrelated")]))).toBe(
|
|
932
|
+
updated,
|
|
933
|
+
);
|
|
934
|
+
});
|
|
935
|
+
});
|
|
936
|
+
|
|
937
|
+
test("handles a top level validation thats not an array", () => {
|
|
938
|
+
const model = withParser(new LocalModel({}), parseBinding);
|
|
939
|
+
const evaluator = new ExpressionEvaluator({ model });
|
|
940
|
+
const schema = new SchemaController();
|
|
941
|
+
|
|
942
|
+
const view = new ViewInstance(
|
|
943
|
+
{
|
|
944
|
+
id: "foo",
|
|
945
|
+
validation: {
|
|
946
|
+
broken: true,
|
|
947
|
+
},
|
|
948
|
+
} as any,
|
|
949
|
+
{
|
|
950
|
+
model,
|
|
951
|
+
parseBinding,
|
|
952
|
+
evaluator,
|
|
953
|
+
schema,
|
|
954
|
+
},
|
|
955
|
+
);
|
|
956
|
+
|
|
957
|
+
expect(view).toBeDefined();
|
|
958
|
+
});
|
|
959
|
+
});
|