forked from opentiny/tiny-vue
fix(collapse): 修复collapse未深度监听导致Pc端tiny-collapse activeNames直接push无法响应的bug (#512)
This commit is contained in:
parent
7f0f027765
commit
0036fcb203
|
@ -33,7 +33,7 @@ export const renderless = (props, { reactive, watch }, { parent, emit, constants
|
|||
(value) => {
|
||||
state.activeNames = value || value === 0 ? [].concat(value) : []
|
||||
},
|
||||
{ immediate: true }
|
||||
{ immediate: true, deep: true }
|
||||
)
|
||||
|
||||
parent.$on(eventName, api.handleItemClick)
|
||||
|
|
|
@ -2,17 +2,22 @@ import { mountPcMode } from '@opentiny-internal/vue-test-utils'
|
|||
import { describe, test, expect, vi } from 'vitest'
|
||||
import Collapse from '@opentiny/vue-collapse'
|
||||
import CollapseItem from '@opentiny/vue-collapse-item'
|
||||
|
||||
import { ref } from 'vue'
|
||||
describe('PC Mode', () => {
|
||||
const mount = mountPcMode
|
||||
|
||||
const handleChange = vi.fn()
|
||||
const activeNames = ref(['1'])
|
||||
const wrapper = mount(() => (
|
||||
<Collapse modelValue="1" onChange={handleChange}>
|
||||
<Collapse modelValue={activeNames.value} onChange={handleChange}>
|
||||
<CollapseItem title="一致性 Consistency" name="1">
|
||||
<div>面板内容1</div>
|
||||
<div>面板内容2</div>
|
||||
</CollapseItem>
|
||||
<CollapseItem title="反馈 Feedback" name="2">
|
||||
<div>面板内容3</div>
|
||||
<div>面板内容4</div>
|
||||
</CollapseItem>
|
||||
</Collapse>
|
||||
))
|
||||
|
||||
|
@ -34,4 +39,11 @@ describe('PC Mode', () => {
|
|||
await wrapper.find('.tiny-collapse-item__header').trigger('click')
|
||||
expect(handleChange).toBeCalled()
|
||||
})
|
||||
})
|
||||
|
||||
// ref test
|
||||
test('ref test', async () => {
|
||||
activeNames.value.push('2')
|
||||
await wrapper.vm.$nextTick()
|
||||
expect(wrapper.find('.is-active').exists()).toBeTruthy()
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue