Skip to content

Commit 4229c93

Browse files
committed
add test for wrong hideEmptyOption value
1 parent 10800f0 commit 4229c93

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/vanilla-renderers/test/renderers/OneOfEnumCell.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,30 @@ describe('OneOfEnum cell', () => {
171171
expect(select.options.item(1).value).toBe('b');
172172
});
173173

174+
test('render with empty option due to wrong hideEmptyOption value', () => {
175+
const core = initCore(fixture.schema, fixture.uischema, fixture.data);
176+
wrapper = mount(
177+
<JsonFormsStateProvider initState={{ core }}>
178+
<OneOfEnumCell
179+
schema={fixture.schema}
180+
uischema={{
181+
...fixture.uischema,
182+
options: { hideEmptyOption: 'true' },
183+
}}
184+
path='foo'
185+
/>
186+
</JsonFormsStateProvider>
187+
);
188+
189+
const select = wrapper.find('select').getDOMNode() as HTMLSelectElement;
190+
expect(select.tagName).toBe('SELECT');
191+
expect(select.value).toBe('a');
192+
expect(select.options).toHaveLength(3);
193+
expect(select.options.item(0).value).toBe('');
194+
expect(select.options.item(1).value).toBe('a');
195+
expect(select.options.item(2).value).toBe('b');
196+
});
197+
174198
test('has classes set', () => {
175199
const core = initCore(fixture.schema, fixture.uischema, fixture.data);
176200
wrapper = mount(

0 commit comments

Comments
 (0)