Skip to content

Commit

Permalink
feat(tree): unit test node-open class render logic
Browse files Browse the repository at this point in the history
  • Loading branch information
NWYLZW committed Nov 23, 2023
1 parent 37796a0 commit 06cb8c4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/tree/__tests__/tree.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,20 @@ describe('Tree test', () => {
expect(onChangeFn1).not.toHaveBeenCalled();
});

it('should calculate right class of tree item.', async () => {
const { container } = await renderTreeWithProps({
expanded: [1, '1-2', '1-2', 2],
});

await mockDelay(300);
const allItems = container.querySelectorAll('.t-tree__item');
expect(allItems.length).toBe(4);
const nodeOpenItems = container.querySelectorAll('.t-tree__item--open');
// only set expanded when node has children
// or children is `true` when the tree is lazy
expect(nodeOpenItems.length).toBe(1);
});

test('props.line', async () => {
const data = [
{
Expand Down

0 comments on commit 06cb8c4

Please sign in to comment.