forked from nuxt-modules/google-fonts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
019772b
commit 31c535c
Showing
1 changed file
with
8 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.') | ||
}) | ||
}) |