2018-03-27 22:28:17 +00:00
|
|
|
import { loadFixture, Nuxt, Generator } from '../utils'
|
2018-03-16 19:52:17 +00:00
|
|
|
|
2018-03-18 19:31:32 +00:00
|
|
|
describe('basic fail generate', () => {
|
|
|
|
test('Fail with routes() which throw an error', async () => {
|
2018-08-17 20:25:23 +00:00
|
|
|
const options = await loadFixture('basic', {
|
2018-03-18 19:31:32 +00:00
|
|
|
generate: {
|
2018-08-10 07:41:23 +00:00
|
|
|
routes() {
|
2018-03-18 19:31:32 +00:00
|
|
|
throw new Error('Not today!')
|
|
|
|
}
|
2016-12-21 19:51:43 +00:00
|
|
|
}
|
2018-03-18 23:41:14 +00:00
|
|
|
})
|
2017-12-17 19:30:26 +00:00
|
|
|
const nuxt = new Nuxt(options)
|
2019-03-08 20:43:23 +00:00
|
|
|
await nuxt.ready()
|
|
|
|
|
2018-03-18 23:41:14 +00:00
|
|
|
const generator = new Generator(nuxt)
|
2017-12-17 19:30:26 +00:00
|
|
|
|
2018-08-06 00:12:44 +00:00
|
|
|
await generator.generate({ build: false }).catch((e) => {
|
2018-03-18 23:41:14 +00:00
|
|
|
expect(e.message).toBe('Not today!')
|
2018-01-13 05:22:11 +00:00
|
|
|
})
|
2018-03-18 23:41:14 +00:00
|
|
|
})
|
2018-09-14 07:06:44 +00:00
|
|
|
|
|
|
|
test('Fail when generate.dir equals rootDir', async () => {
|
|
|
|
const options = await loadFixture('basic', {
|
|
|
|
generate: { dir: '../basic' }
|
|
|
|
})
|
|
|
|
|
|
|
|
expect(() => {
|
|
|
|
new Nuxt(options) /* eslint-disable-line no-new */
|
|
|
|
}).toThrow(/options.generate.dir cannot be/)
|
|
|
|
})
|
2016-12-21 19:51:43 +00:00
|
|
|
})
|