[READ-ONLY] Mirror of https://github.com/danielroe/vue-sanity. Sanity integration for Vue Composition API
composition-api hacktoberfest javascript nuxt sanity typescript vue vuejs
0

Configure Feed

Select the types of activity you want to include in your feed.

vue-sanity / test / utils.spec.ts
815 B 36 lines
1import { describe, expect, it } from 'vitest' 2import { ensureInstance, getServerInstance } from '../src/cache' 3import { runInSetup } from './helpers/mount' 4 5describe('ensureInstance', () => { 6 it('returns component instance', async () => { 7 const data = await runInSetup(() => { 8 const vm = ensureInstance() 9 return { vm } 10 }) 11 12 expect(data.vm).toBeDefined() 13 }) 14 it('errors when called out of setup', async () => { 15 let error = false 16 try { 17 ensureInstance() 18 } 19 catch { 20 error = true 21 } 22 23 expect(error).toBe(true) 24 }) 25}) 26 27describe('getServerInstance', () => { 28 it('returns false when not on server', async () => { 29 const data = await runInSetup(() => { 30 const vm = getServerInstance() 31 return { vm } 32 }) 33 34 expect(data.vm).toBe(false) 35 }) 36})