Skip to content

Commit 0d80122

Browse files
test(@vue-vuetify): test additionalProperties reuses the parent form's AJV
Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Kiara Grouwstra <kiara.grouwstra@gmail.com>
1 parent 6db5bc8 commit 0d80122

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { describe, it, expect, beforeEach } from 'vitest';
2+
import { clearAllIds, createAjv } from '@jsonforms/core';
3+
import { markRaw } from 'vue';
4+
import { extendedVuetifyRenderers } from '../../../src';
5+
import { mountJsonForms } from '../util/util';
6+
7+
// Check that `additionalProperties` reuses the parent form's AJV
8+
describe('AdditionalProperties nested AJV', () => {
9+
// A map whose key `pattern` is legal only without the `u` flag
10+
const schema = {
11+
type: 'object' as const,
12+
properties: {
13+
secretFiles: {
14+
type: 'object' as const,
15+
additionalProperties: { type: 'string' as const },
16+
propertyNames: {
17+
pattern: '^"([^"$\\\\]|\\$(?!{)|\\\\.)*"$',
18+
},
19+
},
20+
},
21+
};
22+
const uischema = { type: 'Control' as const, scope: '#' };
23+
24+
beforeEach(() => {
25+
clearAllIds();
26+
});
27+
28+
it('mounts a map whose key pattern is only valid without the `u` flag', () => {
29+
// A parent form configured with `unicodeRegExp: false`
30+
const ajv = markRaw(createAjv({ unicodeRegExp: false }));
31+
expect(() =>
32+
mountJsonForms(
33+
{ secretFiles: {} },
34+
schema,
35+
extendedVuetifyRenderers,
36+
uischema,
37+
undefined,
38+
undefined,
39+
ajv,
40+
),
41+
).not.toThrow();
42+
});
43+
});

packages/vue-vuetify/tests/unit/util/TestComponent.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:uischema="uischema"
77
:renderers="renderers"
88
:config="config"
9+
:ajv="ajv"
910
:i18n="i18n"
1011
@change="onChange"
1112
/>

packages/vue-vuetify/tests/unit/util/util.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type {
44
JsonSchema,
55
UISchemaElement,
66
} from '@jsonforms/core';
7+
import type Ajv from 'ajv';
78
import { mount } from '@vue/test-utils';
89
import TestComponent from './TestComponent.vue';
910
import { createVuetify } from 'vuetify';
@@ -25,6 +26,7 @@ export const mountJsonForms = (
2526
uischema?: UISchemaElement,
2627
config?: any,
2728
i18n?: JsonFormsI18nState,
29+
ajv?: Ajv,
2830
) => {
2931
return mount(TestComponent, {
3032
global: {
@@ -37,6 +39,7 @@ export const mountJsonForms = (
3739
config,
3840
renderers: markRaw(renderers),
3941
i18n,
42+
ajv,
4043
},
4144
attachTo: document.body,
4245
});

0 commit comments

Comments
 (0)