Skip to content

Commit

Permalink
feat(runtime-dom): add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Doctor-wu committed Jan 21, 2024
1 parent 62cf033 commit 8d9f342
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/runtime-dom/__tests__/directives/vShow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,23 @@ describe('runtime-dom: v-show directive', () => {
// #10151
test('should respect the display value when v-show value is true', async () => {
const isVisible = ref(false)
const useDisplayStyle = ref(true)
const compStyle = ref({
display: 'none',
})
const withoutDisplayStyle = {
margin: '10px',
}

const Component = {
setup() {
return () => {
return withVShow(
h('div', { style: compStyle.value }),
h('div', {
style: useDisplayStyle.value
? compStyle.value
: withoutDisplayStyle,
}),
isVisible.value,
)
}
Expand All @@ -247,6 +255,11 @@ describe('runtime-dom: v-show directive', () => {
await nextTick()
expect($div.style.display).toEqual('inline-block')

useDisplayStyle.value = false
await nextTick()
expect($div.style.display).toEqual('')
expect(getComputedStyle($div).display).toEqual('block')

isVisible.value = false
await nextTick()
expect($div.style.display).toEqual('none')
Expand Down

0 comments on commit 8d9f342

Please sign in to comment.