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
a8ed6ca
commit 27c991a
Showing
10 changed files
with
119 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils') | ||
|
||
describe('basic', () => { | ||
let nuxt | ||
|
||
beforeAll(async () => { | ||
({ nuxt } = (await setup(loadConfig(__dirname, 'basic')))) | ||
}, 60000) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('render', async () => { | ||
const html = await get('/') | ||
expect(html).toContain('<link data-n-head="ssr" rel="dns-prefetch" href="https://fonts.gstatic.com/">') | ||
expect(html).toContain('<link data-n-head="ssr" rel="preconnect" href="https://fonts.gstatic.com/" crossorigin="true">') | ||
expect(html).toContain('<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&family=Lato">') | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { join } = require('path') | ||
const del = require('del') | ||
const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils') | ||
|
||
describe('download', () => { | ||
let nuxt | ||
|
||
beforeAll(async () => { | ||
({ nuxt } = (await setup(loadConfig(__dirname, 'download')))) | ||
}, 60000) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
await del(join(nuxt.options.srcDir, nuxt.options.dir.assets)) | ||
}) | ||
|
||
test('render', async () => { | ||
const html = await get('/') | ||
expect(html).not.toContain('<link data-n-head="ssr" rel="dns-prefetch" href="https://fonts.gstatic.com/">') | ||
expect(html).not.toContain('<link data-n-head="ssr" rel="preconnect" href="https://fonts.gstatic.com/" crossorigin="true">') | ||
expect(html).not.toContain('<link data-n-head="ssr" rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto">') | ||
}) | ||
|
||
test('css inject', () => { | ||
expect(nuxt.options.css).toHaveLength(1) | ||
expect(nuxt.options.css[0]).toContain('css/fonts.css') | ||
}) | ||
}) |
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,11 +1,16 @@ | ||
module.exports = { | ||
rootDir: __dirname, | ||
buildModules: [ | ||
{ handler: require('../') } | ||
{ handler: require('../../../') } | ||
], | ||
head: { | ||
link: [ | ||
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Roboto&display=swap' } | ||
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css?family=Lato' } | ||
] | ||
}, | ||
googleFonts: { | ||
families: { | ||
Roboto: true | ||
} | ||
} | ||
} |
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
rootDir: __dirname, | ||
buildModules: [ | ||
{ handler: require('../../../') } | ||
], | ||
googleFonts: { | ||
download: true, | ||
families: { | ||
Roboto: true | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div> | ||
Works! | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
} | ||
</script> |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
rootDir: __dirname, | ||
buildModules: [ | ||
{ handler: require('../../../') } | ||
] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div> | ||
Works! | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
} | ||
</script> |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { setup, loadConfig } = require('@nuxtjs/module-test-utils') | ||
const logger = require('../lib/logger') | ||
|
||
logger.mockTypes(() => jest.fn()) | ||
|
||
describe('warn', () => { | ||
let nuxt | ||
|
||
beforeAll(async () => { | ||
({ nuxt } = (await setup(loadConfig(__dirname, 'warn')))) | ||
}, 60000) | ||
|
||
beforeEach(() => { | ||
logger.clear() | ||
}) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('should warn if no provided fonts', () => { | ||
expect(logger.warn).toHaveBeenCalledWith('No provided fonts.') | ||
}) | ||
}) |