Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/components/ScriptSetup_ToRefsInject.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<div>
{{ title }}
</div>
<p>{{ type }}</p>
<div v-if="data.length" id="data">Has Data</div>
</template>

<script setup lang="ts">
import { toRefs, ref, inject } from 'vue'

const props = defineProps<{
title: string
}>()

const { title } = toRefs(props)

const type = inject('parentType')

const data = ref<string[]>([])

function getData() {
data.value = ['some data']
}

getData()
</script>
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>
20 changes: 20 additions & 0 deletions tests/features/ScriptSetup_ToRefsInject.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { mount } from '../../src'
import ScriptSetup_ToRefsInject from '../components/ScriptSetup_ToRefsInject.vue'

it('toRefs and inject work with script setup', async () => {
const wrapper = mount(ScriptSetup_ToRefsInject, {
props: {
title: 'Some title'
},
global: {
provide: {
parentType: 'Parent Type'
}
}
})

expect(wrapper.html()).toContain('Some title')
expect(wrapper.find('p').html()).toContain('Parent Type')
expect(wrapper.find('#data').exists()).toBe(true)
expect(wrapper.find('#data').html()).toContain('Has Data')
})
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)
})