diff --git a/test/basic.test.js b/test/basic.test.js
new file mode 100644
index 0000000..b52a527
--- /dev/null
+++ b/test/basic.test.js
@@ -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('')
+ expect(html).toContain('')
+ expect(html).toContain('')
+ })
+})
diff --git a/test/download.test.js b/test/download.test.js
new file mode 100644
index 0000000..63efd80
--- /dev/null
+++ b/test/download.test.js
@@ -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('')
+ expect(html).not.toContain('')
+ expect(html).not.toContain('')
+ })
+
+ test('css inject', () => {
+ expect(nuxt.options.css).toHaveLength(1)
+ expect(nuxt.options.css[0]).toContain('css/fonts.css')
+ })
+})
diff --git a/example/nuxt.config.js b/test/fixture/basic/nuxt.config.js
similarity index 57%
rename from example/nuxt.config.js
rename to test/fixture/basic/nuxt.config.js
index 2822a60..05c1f66 100644
--- a/example/nuxt.config.js
+++ b/test/fixture/basic/nuxt.config.js
@@ -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
+ }
}
}
diff --git a/example/pages/index.vue b/test/fixture/basic/pages/index.vue
similarity index 100%
rename from example/pages/index.vue
rename to test/fixture/basic/pages/index.vue
diff --git a/test/fixture/download/nuxt.config.js b/test/fixture/download/nuxt.config.js
new file mode 100644
index 0000000..0149d85
--- /dev/null
+++ b/test/fixture/download/nuxt.config.js
@@ -0,0 +1,12 @@
+module.exports = {
+ rootDir: __dirname,
+ buildModules: [
+ { handler: require('../../../') }
+ ],
+ googleFonts: {
+ download: true,
+ families: {
+ Roboto: true
+ }
+ }
+}
diff --git a/test/fixture/download/pages/index.vue b/test/fixture/download/pages/index.vue
new file mode 100644
index 0000000..6218ede
--- /dev/null
+++ b/test/fixture/download/pages/index.vue
@@ -0,0 +1,11 @@
+
+
+ Works!
+
+
+
+
diff --git a/test/fixture/warn/nuxt.config.js b/test/fixture/warn/nuxt.config.js
new file mode 100644
index 0000000..936c6b1
--- /dev/null
+++ b/test/fixture/warn/nuxt.config.js
@@ -0,0 +1,6 @@
+module.exports = {
+ rootDir: __dirname,
+ buildModules: [
+ { handler: require('../../../') }
+ ]
+}
diff --git a/test/fixture/warn/pages/index.vue b/test/fixture/warn/pages/index.vue
new file mode 100644
index 0000000..6218ede
--- /dev/null
+++ b/test/fixture/warn/pages/index.vue
@@ -0,0 +1,11 @@
+
+
+ Works!
+
+
+
+
diff --git a/test/module.test.js b/test/module.test.js
deleted file mode 100644
index 64fc707..0000000
--- a/test/module.test.js
+++ /dev/null
@@ -1,18 +0,0 @@
-const { setup, loadConfig, get } = require('@nuxtjs/module-test-utils')
-
-describe('module', () => {
- let nuxt
-
- beforeAll(async () => {
- ({ nuxt } = (await setup(loadConfig(__dirname, '../../example'))))
- }, 60000)
-
- afterAll(async () => {
- await nuxt.close()
- })
-
- test('render', async () => {
- const html = await get('/')
- expect(html).toContain('Works!')
- })
-})
diff --git a/test/warn.test.js b/test/warn.test.js
new file mode 100644
index 0000000..5988ed9
--- /dev/null
+++ b/test/warn.test.js
@@ -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.')
+ })
+})