diff --git a/test/basic.fail.generate.test.js b/test/basic.fail.generate.test.js index 034a6f3365..9750e812f3 100644 --- a/test/basic.fail.generate.test.js +++ b/test/basic.fail.generate.test.js @@ -1,42 +1,16 @@ import test from 'ava' import { resolve } from 'path' -test('Fail to generate without routeParams', t => { - const Nuxt = require('../') - const options = { - rootDir: resolve(__dirname, 'fixtures/basic'), - dev: false - // no generate.routeParams - } - const nuxt = new Nuxt(options) - return new Promise((resolve) => { - var oldExit = process.exit - var oldCE = console.error // eslint-disable-line no-console - var _log = '' - console.error = (s) => { _log += s } // eslint-disable-line no-console - process.exit = (code) => { - process.exit = oldExit - console.error = oldCE // eslint-disable-line no-console - t.is(code, 1) - t.true(_log.includes('Could not generate the dynamic route /users/:id')) - resolve() - } - nuxt.generate() - }) -}) - -test('Fail with routeParams which throw an error', t => { +test('Fail with routes() which throw an error', t => { const Nuxt = require('../') const options = { rootDir: resolve(__dirname, 'fixtures/basic'), dev: false, generate: { - routeParams: { - '/users/:id': function () { - return new Promise((resolve, reject) => { - reject('Not today!') - }) - } + routes: function () { + return new Promise((resolve, reject) => { + reject('Not today!') + }) } } } @@ -50,7 +24,7 @@ test('Fail with routeParams which throw an error', t => { process.exit = oldExit console.error = oldCE // eslint-disable-line no-console t.is(code, 1) - t.true(_log.includes('Could not resolve routeParams[/users/:id]')) + t.true(_log.includes('Could not resolve routes')) resolve() } nuxt.generate() diff --git a/test/fixtures/basic/nuxt.config.js b/test/fixtures/basic/nuxt.config.js index 13d5d0cef5..19c0433cab 100644 --- a/test/fixtures/basic/nuxt.config.js +++ b/test/fixtures/basic/nuxt.config.js @@ -1,11 +1,9 @@ module.exports = { generate: { - routeParams: { - '/users/:id?': [ - { id: 1 }, - { id: 2 }, - { id: 3 } - ] - } + routes: [ + '/users/1', + '/users/2', + '/users/3' + ] } } diff --git a/test/utils.test.js b/test/utils.test.js index e7421a0bb2..3b80dc2c70 100644 --- a/test/utils.test.js +++ b/test/utils.test.js @@ -37,9 +37,9 @@ test('urlJoin', t => { t.is(utils.urlJoin('test', '/about'), 'test/about') }) -test('promisifyRouteParams (array)', t => { +test('promisifyRoute (array)', t => { const array = [1] - const promise = utils.promisifyRouteParams(array) + const promise = utils.promisifyRoute(array) t.is(typeof promise, 'object') return promise .then((res) => { @@ -47,12 +47,12 @@ test('promisifyRouteParams (array)', t => { }) }) -test('promisifyRouteParams (fn => array)', t => { +test('promisifyRoute (fn => array)', t => { const array = [1, 2] const fn = function () { return array } - const promise = utils.promisifyRouteParams(fn) + const promise = utils.promisifyRoute(fn) t.is(typeof promise, 'object') return promise .then((res) => { @@ -60,14 +60,14 @@ test('promisifyRouteParams (fn => array)', t => { }) }) -test('promisifyRouteParams (fn => promise)', t => { +test('promisifyRoute (fn => promise)', t => { const array = [1, 2, 3] const fn = function () { return new Promise((resolve) => { resolve(array) }) } - const promise = utils.promisifyRouteParams(fn) + const promise = utils.promisifyRoute(fn) t.is(typeof promise, 'object') return promise .then((res) => { @@ -75,11 +75,11 @@ test('promisifyRouteParams (fn => promise)', t => { }) }) -test('promisifyRouteParams (fn(cb) with error)', t => { +test('promisifyRoute (fn(cb) with error)', t => { const fn = function (cb) { cb('Error here') } - const promise = utils.promisifyRouteParams(fn) + const promise = utils.promisifyRoute(fn) t.is(typeof promise, 'object') return promise .catch((e) => { @@ -87,12 +87,12 @@ test('promisifyRouteParams (fn(cb) with error)', t => { }) }) -test('promisifyRouteParams (fn(cb) with result)', t => { +test('promisifyRoute (fn(cb) with result)', t => { const array = [1, 2, 3, 4] const fn = function (cb) { cb(null, array) } - const promise = utils.promisifyRouteParams(fn) + const promise = utils.promisifyRoute(fn) t.is(typeof promise, 'object') return promise .then((res) => {