mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-04 04:08:34 +08:00
fix(components): [el-cascader] empty children set leaf (#3758)
* fix(components): [el-cascader] empty children set leaf * test: add test
This commit is contained in:
parent
e9a110ed47
commit
c6c1e965f7
@ -35,6 +35,11 @@ const NORMAL_OPTIONS = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
value: 'guangdong',
|
||||
label: 'Guangdong',
|
||||
children: [],
|
||||
},
|
||||
]
|
||||
|
||||
const DISABLED_OPTIONS = [
|
||||
@ -154,12 +159,14 @@ describe('CascaderPanel.vue', () => {
|
||||
})
|
||||
|
||||
const options = wrapper.findAll(NODE)
|
||||
const [bjNode, zjNode] = options
|
||||
const [bjNode, zjNode, , gdNode] = options
|
||||
|
||||
expect(wrapper.findAll(MENU).length).toBe(1)
|
||||
expect(options.length).toBe(3)
|
||||
expect(options.length).toBe(4)
|
||||
expect(bjNode.text()).toBe('Beijing')
|
||||
expect(bjNode.find(EXPAND_ARROW).exists()).toBe(false)
|
||||
expect(zjNode.find(EXPAND_ARROW).exists()).toBe(true)
|
||||
expect(gdNode.find(EXPAND_ARROW).exists()).toBe(false)
|
||||
|
||||
await zjNode.trigger('click')
|
||||
const menus = wrapper.findAll(MENU)
|
||||
@ -178,6 +185,12 @@ describe('CascaderPanel.vue', () => {
|
||||
expect(handleExpandChange).toBeCalledTimes(2)
|
||||
expect(handleChange).toBeCalledTimes(2)
|
||||
expect(wrapper.vm.value).toEqual(['beijing'])
|
||||
|
||||
await gdNode.trigger('click')
|
||||
expect(wrapper.findAll(MENU).length).toBe(1)
|
||||
expect(handleExpandChange).toBeCalledTimes(3)
|
||||
expect(handleChange).toBeCalledTimes(3)
|
||||
expect(wrapper.vm.value).toEqual(['guangdong'])
|
||||
})
|
||||
|
||||
test('with default value', async () => {
|
||||
|
@ -120,7 +120,7 @@ class Node {
|
||||
return isUndefined(isLeaf)
|
||||
? lazy && !loaded
|
||||
? false
|
||||
: !Array.isArray(childrenData)
|
||||
: !(Array.isArray(childrenData) && childrenData.length)
|
||||
: !!isLeaf
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user