From 81bb278305af150e0b86cb82f1a8a9112c581c99 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Fri, 8 Dec 2017 15:39:58 +0800 Subject: [PATCH] test: build.styleResources for style-resources-loader --- test/fixtures/with-config/nuxt.config.js | 5 +++++ test/with-config.test.js | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/test/fixtures/with-config/nuxt.config.js b/test/fixtures/with-config/nuxt.config.js index bd564d5e8a..08f6cad227 100644 --- a/test/fixtures/with-config/nuxt.config.js +++ b/test/fixtures/with-config/nuxt.config.js @@ -48,6 +48,11 @@ module.exports = { analyzerMode: 'disabled', generateStatsFile: true }, + styleResources: { + patterns: [ + '~/assets/pre-process.scss' + ] + }, extend(config, options) { return Object.assign({}, config, { devtool: 'nosources-source-map' diff --git a/test/with-config.test.js b/test/with-config.test.js index 0dd726da0c..b04e56c8ed 100644 --- a/test/with-config.test.js +++ b/test/with-config.test.js @@ -7,6 +7,7 @@ const port = 4007 const url = (route) => 'http://localhost:' + port + route let nuxt = null +let builder = null // Init nuxt.js and create server listening on localhost:4000 test.before('Init Nuxt.js', async t => { @@ -15,7 +16,8 @@ test.before('Init Nuxt.js', async t => { config.rootDir = rootDir config.dev = false nuxt = new Nuxt(config) - await new Builder(nuxt).build() + builder = new Builder(nuxt) + await builder.build() await nuxt.listen(port, 'localhost') }) @@ -128,6 +130,17 @@ test('Check /test.txt should return 404', async t => { t.is(err.response.statusCode, 404) }) +test('Check build.styleResources for style-resources-loader', async t => { + const loaders = builder.styleLoader('scss') + const loader = loaders.find(l => l.loader === 'style-resources-loader') + t.is(typeof loader, 'object') + t.deepEqual(loader.options, { + patterns: [ + '~/assets/pre-process.scss' + ] + }) +}) + // Close server and ask nuxt to stop listening to file changes test.after('Closing server and nuxt.js', t => { nuxt.close()