From 0eb3fc4a05e153c6565bc85bad66caba50c8270f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 15 May 2017 03:31:41 +0430 Subject: [PATCH] update tests --- lib/generate.js | 5 +++-- lib/module.js | 5 ++++- lib/utils.js | 1 + test/fixtures/module/modules/basic/index.js | 15 +++++++++++++++ test/fixtures/module/modules/middleware/index.js | 6 ++++++ 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/generate.js b/lib/generate.js index 228f617a32..be9867a589 100644 --- a/lib/generate.js +++ b/lib/generate.js @@ -96,12 +96,12 @@ export default async function () { if (error) { errors.push({ type: 'handled', route, error }) } - } catch (err) { + } catch (err) /* istanbul ignore next */ { errors.push({ type: 'unhandled', route, error: err }) } try { var minifiedHtml = minify(html, self.options.generate.minify) - } catch (err) { + } catch (err) /* istanbul ignore next */ { let minifyErr = new Error(`HTML minification failed. Make sure the route generates valid HTML. Failed HTML:\n ${html}`) errors.push({ type: 'unhandled', route, error: minifyErr }) } @@ -122,6 +122,7 @@ export default async function () { if (errors.length) { const report = errors.map(({ type, route, error }) => { + /* istanbul ignore if */ if (type === 'unhandled') { return `Route: '${route}'\n${error.stack}` } else { diff --git a/lib/module.js b/lib/module.js index 62b6776795..a894aded9a 100755 --- a/lib/module.js +++ b/lib/module.js @@ -13,6 +13,7 @@ class Module { } addVendor (vendor) { + /* istanbul ignore if */ if (!vendor) { return } @@ -20,6 +21,7 @@ class Module { } addTemplate (template) { + /* istanbul ignore if */ if (!template) { return } @@ -74,6 +76,7 @@ class Module { } installModule (moduleOpts) { + /* istanbul ignore if */ if (!moduleOpts) { return } @@ -91,7 +94,7 @@ class Module { // eslint-disable-next-line no-eval module = eval('require')(src) } - } /* istanbul ignore next */ catch (e) { + } catch (e) /* istanbul ignore next */ { // eslint-disable-next-line no-console console.error('[Nuxt] Unable to resolve module', src) // eslint-disable-next-line no-console diff --git a/lib/utils.js b/lib/utils.js index 4ef641369c..1a39b9537c 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -63,6 +63,7 @@ export function sequence (tasks, fn) { } export function chainFn (base, fn) { + /* istanbul ignore if */ if (!(fn instanceof Function)) { return } diff --git a/test/fixtures/module/modules/basic/index.js b/test/fixtures/module/modules/basic/index.js index 675b661201..5e1513a782 100755 --- a/test/fixtures/module/modules/basic/index.js +++ b/test/fixtures/module/modules/basic/index.js @@ -7,5 +7,20 @@ module.exports = function basicModule (options, resolve) { // Add a plugin this.addPlugin(path.resolve(__dirname, 'reverse.js')) + // Extend build + this.extendBuild(({isClient, isServer}) => { + // Do nothing! + }) + + // Extend build again + this.extendBuild(({isClient, isServer}) => { + // Do nothing! + }) + + // Extend routes + this.extendRoutes((routes, resolve) => { + // Do nothing! + }) + resolve() } diff --git a/test/fixtures/module/modules/middleware/index.js b/test/fixtures/module/modules/middleware/index.js index 277e3aaefc..2c5da9afaa 100755 --- a/test/fixtures/module/modules/middleware/index.js +++ b/test/fixtures/module/modules/middleware/index.js @@ -8,5 +8,11 @@ module.exports = function middlewareModule (options) { res.end('It works!') } }) + // Add plain middleware + this.addServerMiddleware((req, res, next) => { + next() + }) + // Resolve + resolve() }) }