Skip to content

Commit 2b8f4c7

Browse files
committed
chore: add unit test
1 parent 0dd12df commit 2b8f4c7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/Select.multiple.spec.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,4 +310,42 @@ describe('TreeSelect.multiple', () => {
310310
).map(ele => ele.textContent);
311311
expect(values).toEqual(['child1', 'child2', 'parent']);
312312
});
313+
314+
// https://github.com/ant-design/ant-design/issues/50578#issuecomment-2312130715
315+
it('should not omit value when value is null', () => {
316+
const { container } = render(
317+
<TreeSelect
318+
value={null}
319+
multiple
320+
placeholder="Fake placeholder"
321+
treeData={[
322+
{
323+
label: 'parent',
324+
value: 'parent',
325+
children: [
326+
{
327+
label: 'child1',
328+
value: 'child1',
329+
},
330+
{
331+
label: 'child2',
332+
value: 'child2',
333+
},
334+
],
335+
},
336+
]}
337+
/>,
338+
);
339+
340+
const values = Array.from(
341+
container.querySelectorAll('.rc-tree-select-selection-item-content'),
342+
); //.map(ele => ele.textContent);
343+
344+
expect(values).toHaveLength(0);
345+
346+
const placeholder = container.querySelector('[class$=placeholder]');
347+
expect(placeholder).toBeTruthy();
348+
expect(placeholder.textContent).toBe('Fake placeholder');
349+
});
350+
313351
});

0 commit comments

Comments
 (0)