-
Notifications
You must be signed in to change notification settings - Fork 422
Expand file tree
/
Copy pathArrayControlRenderer.spec.ts
More file actions
56 lines (48 loc) · 1.6 KB
/
ArrayControlRenderer.spec.ts
File metadata and controls
56 lines (48 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import { describe, it, expect, beforeEach } from 'vitest';
import { clearAllIds, createTranslator } from '@jsonforms/core';
import ArrayControlRenderer from '../../../src/complex/ArrayControlRenderer.vue';
import { entry as arrayControlRendererEntry } from '../../../src/complex/ArrayControlRenderer.entry';
import { mountJsonForms } from '../util';
describe('ArrayControlRenderer.vue', () => {
const renderers = [arrayControlRendererEntry];
const data: unknown[] = [];
const schema = {
type: 'array',
items: {
type: 'object',
properties: {
name: { type: 'string' },
done: { type: 'boolean' },
},
},
};
const uischema = {
type: 'Control',
scope: '#',
};
let wrapper: ReturnType<typeof mountJsonForms>;
beforeEach(() => {
// clear all ids to guarantee that the snapshots will always be generated with the same ids
clearAllIds();
wrapper = mountJsonForms(data, schema, renderers, uischema, undefined, {
translate: createTranslator((id, defaultMessage) => {
if (id.endsWith('addAriaLabel')) {
return 'MyAdd';
}
return defaultMessage;
}),
});
});
it('check if child ArrayControl exists', () => {
expect(wrapper.getComponent(ArrayControlRenderer));
});
it('renders an add button', () => {
expect(wrapper.find('.array-list-add').exists()).toBeTruthy();
});
it('respects translations', () => {
expect(wrapper.find('[aria-label="MyAdd"]').exists()).toBeTruthy();
});
it('should render component and match snapshot', () => {
expect(wrapper.html()).toMatchSnapshot();
});
});