From ba5e608302dbddad73d17d8dbd720ef28adfa749 Mon Sep 17 00:00:00 2001 From: Ricardo Gobbo de Souza Date: Sat, 3 Feb 2018 09:10:58 -0200 Subject: [PATCH] test: rename custom-pages to custom-dirs and include tests for assets --- test/{custom.pages.dir.js => custom-dirs.test.js} | 9 +++++++-- test/fixtures/custom-dirs/custom-assets/app.css | 3 +++ .../custom-pages/index.vue | 0 test/fixtures/custom-dirs/nuxt.config.js | 5 +++++ .../{custom-pages-dir => custom-dirs}/package.json | 2 +- test/fixtures/custom-pages-dir/nuxt.config.js | 3 --- 6 files changed, 16 insertions(+), 6 deletions(-) rename test/{custom.pages.dir.js => custom-dirs.test.js} (78%) create mode 100644 test/fixtures/custom-dirs/custom-assets/app.css rename test/fixtures/{custom-pages-dir => custom-dirs}/custom-pages/index.vue (100%) create mode 100644 test/fixtures/custom-dirs/nuxt.config.js rename test/fixtures/{custom-pages-dir => custom-dirs}/package.json (61%) delete mode 100644 test/fixtures/custom-pages-dir/nuxt.config.js diff --git a/test/custom.pages.dir.js b/test/custom-dirs.test.js similarity index 78% rename from test/custom.pages.dir.js rename to test/custom-dirs.test.js index 00400c21fa..cd311a6f1b 100644 --- a/test/custom.pages.dir.js +++ b/test/custom-dirs.test.js @@ -8,7 +8,7 @@ let builder = null // Init nuxt.js and create server listening on localhost:4000 test.before('Init Nuxt.js', async t => { - const rootDir = resolve(__dirname, 'fixtures/custom-pages-dir') + const rootDir = resolve(__dirname, 'fixtures/custom-dirs') let config = require(resolve(rootDir, 'nuxt.config.js')) config.rootDir = rootDir config.dev = false @@ -24,11 +24,16 @@ test.before('Init Nuxt.js', async t => { t.true(logSpy.calledWithMatch('OPEN')) }) -test('/', async t => { +test('/ (custom pages directory)', async t => { const { html } = await nuxt.renderRoute('/') t.true(html.includes('

I have custom pages directory

')) }) +test('/ (custom assets directory)', async t => { + const { html } = await nuxt.renderRoute('/') + t.true(html.includes('.global-css-selector')) +}) + // Close server and ask nuxt to stop listening to file changes test.after.always('Closing server and nuxt.js', async t => { await nuxt.close() diff --git a/test/fixtures/custom-dirs/custom-assets/app.css b/test/fixtures/custom-dirs/custom-assets/app.css new file mode 100644 index 0000000000..f69fcd8bbc --- /dev/null +++ b/test/fixtures/custom-dirs/custom-assets/app.css @@ -0,0 +1,3 @@ +.global-css-selector { + color: red; +} diff --git a/test/fixtures/custom-pages-dir/custom-pages/index.vue b/test/fixtures/custom-dirs/custom-pages/index.vue similarity index 100% rename from test/fixtures/custom-pages-dir/custom-pages/index.vue rename to test/fixtures/custom-dirs/custom-pages/index.vue diff --git a/test/fixtures/custom-dirs/nuxt.config.js b/test/fixtures/custom-dirs/nuxt.config.js new file mode 100644 index 0000000000..2ca07b3cb5 --- /dev/null +++ b/test/fixtures/custom-dirs/nuxt.config.js @@ -0,0 +1,5 @@ +module.exports = { + assetsDir: 'custom-assets', + pagesDir: 'custom-pages', + css: [{ src: '~/custom-assets/app.css' }] +} diff --git a/test/fixtures/custom-pages-dir/package.json b/test/fixtures/custom-dirs/package.json similarity index 61% rename from test/fixtures/custom-pages-dir/package.json rename to test/fixtures/custom-dirs/package.json index de28318ece..d3db7bec4d 100644 --- a/test/fixtures/custom-pages-dir/package.json +++ b/test/fixtures/custom-dirs/package.json @@ -1,5 +1,5 @@ { - "name": "custom-pages-dir", + "name": "custom-dirs", "version": "1.0.0", "dependencies": {} } diff --git a/test/fixtures/custom-pages-dir/nuxt.config.js b/test/fixtures/custom-pages-dir/nuxt.config.js deleted file mode 100644 index 0cf6019e1d..0000000000 --- a/test/fixtures/custom-pages-dir/nuxt.config.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - pagesDir: 'custom-pages' -}