Skip to content

Commit 8d9f342

Browse files
committed
feat(runtime-dom): add test cases
1 parent 62cf033 commit 8d9f342

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

packages/runtime-dom/__tests__/directives/vShow.spec.ts

+14-1
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,23 @@ describe('runtime-dom: v-show directive', () => {
215215
// #10151
216216
test('should respect the display value when v-show value is true', async () => {
217217
const isVisible = ref(false)
218+
const useDisplayStyle = ref(true)
218219
const compStyle = ref({
219220
display: 'none',
220221
})
222+
const withoutDisplayStyle = {
223+
margin: '10px',
224+
}
221225

222226
const Component = {
223227
setup() {
224228
return () => {
225229
return withVShow(
226-
h('div', { style: compStyle.value }),
230+
h('div', {
231+
style: useDisplayStyle.value
232+
? compStyle.value
233+
: withoutDisplayStyle,
234+
}),
227235
isVisible.value,
228236
)
229237
}
@@ -247,6 +255,11 @@ describe('runtime-dom: v-show directive', () => {
247255
await nextTick()
248256
expect($div.style.display).toEqual('inline-block')
249257

258+
useDisplayStyle.value = false
259+
await nextTick()
260+
expect($div.style.display).toEqual('')
261+
expect(getComputedStyle($div).display).toEqual('block')
262+
250263
isVisible.value = false
251264
await nextTick()
252265
expect($div.style.display).toEqual('none')

0 commit comments

Comments
 (0)