Skip to content

Commit

Permalink
style: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Sep 27, 2023
1 parent 8da186c commit 91723ac
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/vitest-environment-nuxt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export default <Environment>{
}

const h3App = createApp()

if (!win.fetch) {
await import('node-fetch-native/polyfill')
// @ts-expect-error URLSearchParams is not a proeprty of window
Expand Down
8 changes: 4 additions & 4 deletions src/vitest-environment-nuxt/runtime/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {
h,
nextTick,
} from 'vue'
import type {
RenderOptions as TestingLibraryRenderOptions,
} from '@testing-library/vue'
import type { RenderOptions as TestingLibraryRenderOptions } from '@testing-library/vue'
import { defu } from 'defu'
import type { RouteLocationRaw } from 'vue-router'

Expand Down Expand Up @@ -66,7 +64,9 @@ export async function renderSuspended<T>(
..._options
} = options || {}

const { render : renderFromTestingLibrary } = await import('@testing-library/vue')
const { render: renderFromTestingLibrary } = await import(
'@testing-library/vue'
)

// @ts-ignore untyped global __unctx__
const { vueApp } = globalThis.__unctx__.get('nuxt-app').tryUse()
Expand Down
26 changes: 16 additions & 10 deletions test/fixtures/nuxt-vitest/tests/nuxt/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ describe('client-side nuxt features', () => {

it('allows pushing to other pages', async () => {
await navigateTo('/something')
expect(useNuxtApp().$router.currentRoute.value.path).toEqual(
'/something'
)
expect(useNuxtApp().$router.currentRoute.value.path).toEqual('/something')
// It takes a few ticks for the Nuxt useRoute to be updated (as, after suspense resolves,
// we wait for a final hook and then update the injected route object )
const route = useRoute()
await new Promise<void>(resolve => {
const unsub = watch(() => route.path, path => {
if (path === '/something') {
unsub()
resolve()
const unsub = watch(
() => route.path,
path => {
if (path === '/something') {
unsub()
resolve()
}
}
})
)
})
expect(route.path).toEqual('/something')
})
Expand Down Expand Up @@ -115,10 +116,15 @@ describe('test utils', () => {
})

it('can use $fetch', async () => {
const app = createApp().use('/todos/1', eventHandler(() => ({ id: 1 })))
const app = createApp().use(
'/todos/1',
eventHandler(() => ({ id: 1 }))
)
const server = await listen(toNodeListener(app))
const [{ url }] = await server.getURLs()
expect(await $fetch<unknown>('/todos/1', { baseURL: url })).toMatchObject({ id: 1 })
expect(await $fetch<unknown>('/todos/1', { baseURL: url })).toMatchObject({
id: 1,
})
await server.close()
})

Expand Down

0 comments on commit 91723ac

Please sign in to comment.