Skip to content

Commit

Permalink
chore: add watchEffect and script setup example
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiller1990 committed Aug 24, 2021
1 parent cd223f9 commit 8d2f87a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
22 changes: 22 additions & 0 deletions tests/components/ScriptSetup_WatchEffect.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<template>
<div v-if="hasContent">
<div id="contentInfo" />
</div>

<div v-else>
<div id="noContent" />
</div>
</template>

<script setup>
import { ref, watchEffect, inject } from 'vue'
const type = inject('someType')
const hasContent = ref(false)
watchEffect(() => {
if (type === 'content') {
hasContent.value = true
}
})
</script>
2 changes: 1 addition & 1 deletion tests/features/ScriptSetup_ToRefsInject.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mount } from '../../src'
import ScriptSetup_ToRefsInject from '../components/ScriptSetup_ToRefsInject.vue'

it('', async () => {
it('toRefs and inject work with script setup', async () => {
const wrapper = mount(ScriptSetup_ToRefsInject, {
props: {
title: 'Some title'
Expand Down
12 changes: 12 additions & 0 deletions tests/features/ScriptSetup_WatchEffect.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { mount } from '../../src'
import ScriptSetup_WatchEffect from '../components/ScriptSetup_WatchEffect.vue'

it('watchEffect works with script setup', () => {
const wrapper = mount(ScriptSetup_WatchEffect, {
global: {
provide: { someType: 'content' }
}
})

expect(wrapper.find('#contentInfo').exists()).toBe(true)
})

0 comments on commit 8d2f87a

Please sign in to comment.