2020-12-17 13:34:53 +00:00
|
|
|
import { loadFixture, Nuxt, Builder, BundleBuilder } from './index'
|
2018-03-27 22:28:17 +00:00
|
|
|
|
2020-12-17 13:34:53 +00:00
|
|
|
export const buildFixture = function (fixture, callback, hooks = [], overrides) {
|
2018-09-18 14:26:41 +00:00
|
|
|
let nuxt
|
|
|
|
|
2018-03-27 22:28:17 +00:00
|
|
|
test(`Build ${fixture}`, async () => {
|
2020-12-17 13:34:53 +00:00
|
|
|
const config = await loadFixture(fixture, overrides)
|
2018-09-18 14:26:41 +00:00
|
|
|
nuxt = new Nuxt(config)
|
|
|
|
|
2018-03-27 22:28:17 +00:00
|
|
|
const buildDone = jest.fn()
|
2018-09-08 20:18:14 +00:00
|
|
|
hooks.forEach(([hook, fn]) => nuxt.hook(hook, fn))
|
2018-03-27 22:28:17 +00:00
|
|
|
nuxt.hook('build:done', buildDone)
|
2018-10-31 15:52:35 +00:00
|
|
|
const builder = await new Builder(nuxt, BundleBuilder).build()
|
2018-03-27 22:28:17 +00:00
|
|
|
// 2: BUILD_DONE
|
|
|
|
expect(builder._buildStatus).toBe(2)
|
|
|
|
expect(buildDone).toHaveBeenCalledTimes(1)
|
2018-08-16 15:34:32 +00:00
|
|
|
if (typeof callback === 'function') {
|
|
|
|
callback(builder)
|
|
|
|
}
|
2018-07-24 16:24:10 +00:00
|
|
|
}, 120000)
|
2018-03-27 22:28:17 +00:00
|
|
|
}
|