mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
88c9bae57b
* feat: add tests to check for changed files Make sure that if we are building or generating only files in buildDir and generate.dir are changed. If files in another location would also be changed due to a new config option, those locations should be guarded in lib/common/options so you cant set them lower then rootDir or srcDir. * fix running tests inBand use simpler path comparisons * add debug logs for ci use process.hrtime for waitFor test * add debug logs for ci use process.hrtime for waitFor test * use writeFileSync should probably help * use forEach instead of map when not returning a value update waitFor test to compare values with jest * fix appeveyor * use lower limit than delay in waitFor test revert isAppveyor export
78 lines
2.0 KiB
JavaScript
78 lines
2.0 KiB
JavaScript
import { Nuxt, Generator } from '../utils'
|
|
|
|
describe('generator', () => {
|
|
test('initRoutes with routes (fn => array)', async () => {
|
|
const array = ['/1', '/2', '/3', '/4']
|
|
const config = {
|
|
generate: {
|
|
routes: array
|
|
}
|
|
}
|
|
const nuxt = new Nuxt(config)
|
|
const generator = new Generator(nuxt)
|
|
const routes = await generator.initRoutes()
|
|
|
|
expect(routes.length).toBe(array.length)
|
|
routes.forEach((route, index) => {
|
|
expect(route.route).toBe(array[index])
|
|
})
|
|
})
|
|
|
|
test('initRoutes with routes (fn())', async () => {
|
|
const array = ['/1', '/2', '/3', '/4']
|
|
const config = {
|
|
generate: {
|
|
routes() {
|
|
return array
|
|
}
|
|
}
|
|
}
|
|
const nuxt = new Nuxt(config)
|
|
const generator = new Generator(nuxt)
|
|
const routes = await generator.initRoutes()
|
|
|
|
expect(routes.length).toBe(array.length)
|
|
routes.forEach((route, index) => {
|
|
expect(route.route).toBe(array[index])
|
|
})
|
|
})
|
|
|
|
test('initRoutes with routes (fn(args))', async () => {
|
|
const config = {
|
|
generate: {
|
|
routes(array) {
|
|
return array
|
|
}
|
|
}
|
|
}
|
|
const nuxt = new Nuxt(config)
|
|
const generator = new Generator(nuxt)
|
|
const array = ['/1', '/2', '/3', '/4']
|
|
const routes = await generator.initRoutes(array)
|
|
|
|
expect(routes.length).toBe(array.length)
|
|
routes.forEach((route, index) => {
|
|
expect(route.route).toBe(array[index])
|
|
})
|
|
})
|
|
|
|
test('initRoutes with routes (fn(cb, args))', async () => {
|
|
const config = {
|
|
generate: {
|
|
routes(cb, arg1, arg2, arg3, arg4) {
|
|
cb(null, [arg1, arg2, arg3, arg4])
|
|
}
|
|
}
|
|
}
|
|
const nuxt = new Nuxt(config)
|
|
const generator = new Generator(nuxt)
|
|
const array = ['/1', '/2', '/3', '/4']
|
|
const routes = await generator.initRoutes(...array)
|
|
|
|
expect(routes.length).toBe(array.length)
|
|
routes.forEach((route, index) => {
|
|
expect(route.route).toBe(array[index])
|
|
})
|
|
})
|
|
})
|