Skip to content

Commit

Permalink
test: update
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza committed May 18, 2023
1 parent 019772b commit 31c535c
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions test/warn.test.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
import { describe, test, expect, vi } from 'vitest'
import { describe, test, expect, vi, afterAll } from 'vitest'
import { setup } from '@nuxt/test-utils'
import consola from 'consola'

export function mockLogger (): typeof consola {
const mock = {}
describe('warn', async () => {
const spyStderr = vi.spyOn(process.stderr, 'write').mockImplementation(() => undefined!)

consola.mockTypes((type) => {
mock[type] = mock[type] || vi.fn()
return mock[type]
afterAll(() => {
spyStderr.mockRestore()
})

// @ts-ignore
return mock
}

const logger = mockLogger()

describe('warn', async () => {
await setup({
server: false
})

test('should warn if no provided fonts', () => {
expect(logger.warn).toHaveBeenCalledWith('No provided fonts.')
expect(spyStderr).toBeCalledTimes(1)
const output = spyStderr.mock.calls[0][0].toString()
expect(output).contains('[warn] [nuxt:google-fonts] No provided fonts.')
})
})

0 comments on commit 31c535c

Please sign in to comment.