Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
edison1105 committed Sep 16, 2021
1 parent 76e719b commit 8f6c1e0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/runtime-dom/__tests__/helpers/useCssVars.spec.ts
Expand Up @@ -8,6 +8,7 @@ import {
nextTick,
ComponentOptions,
Suspense,
Teleport,
FunctionalComponent
} from '@vue/runtime-dom'

Expand Down Expand Up @@ -196,4 +197,23 @@ describe('useCssVars', () => {
expect((c as HTMLElement).style.getPropertyValue(`--color`)).toBe('red')
}
})

test('with teleport', async () => {
const state = reactive({ color: 'red' })
const root = document.createElement('div')
const target = document.createElement('div')

const App = {
setup() {
useCssVars(() => state)
return () => [h(Teleport, { to: target }, [h('div')])]
}
}

render(h(App), root)
await nextTick()
for (const c of [].slice.call(target.children as any)) {
expect((c as HTMLElement).style.getPropertyValue(`--color`)).toBe('red')
}
})
})

0 comments on commit 8f6c1e0

Please sign in to comment.