forked from Tencent/tdesign-vue
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tree): 解决 tree 组件指定 keys 属性后,next 版本可能导致 dom 无限刷新的问题
fix Tencent#445
- Loading branch information
Showing
2 changed files
with
66 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import Tree from '@/src/tree/index.ts'; | ||
|
||
describe('Tree:keys', () => { | ||
jest.useRealTimers(); | ||
describe(':props.keys', () => { | ||
it('可指定树结构监听分配的属性', async () => { | ||
const data = [ | ||
{ | ||
id: 't1', | ||
name: 'node.t1', | ||
subnodes: [ | ||
{ | ||
id: 't1.1', | ||
name: 'node.t1.1', | ||
}, | ||
{ | ||
id: 't1.2', | ||
name: 'node.t1.2', | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const keys = { | ||
value: 'id', | ||
label: 'name', | ||
children: 'subnodes', | ||
}; | ||
|
||
const wrapper = mount({ | ||
data() { | ||
return {}; | ||
}, | ||
render() { | ||
return <Tree keys={keys} data={data} expandAll></Tree>; | ||
}, | ||
}); | ||
|
||
const t1 = wrapper.find('[data-value="t1"]'); | ||
const t1d1 = wrapper.find('[data-value="t1.1"]'); | ||
const t1d2 = wrapper.find('[data-value="t1.2"]'); | ||
|
||
expect(t1.exists()).toBe(true); | ||
expect(t1d1.exists()).toBe(true); | ||
expect(t1d2.exists()).toBe(true); | ||
|
||
expect(t1.text()).toBe('node.t1'); | ||
expect(t1d1.text()).toBe('node.t1.1'); | ||
expect(t1d2.text()).toBe('node.t1.2'); | ||
}); | ||
}); | ||
}); |