test: add test for dll

This commit is contained in:
Clark Du 2017-10-29 18:24:58 +08:00 committed by Pooya Parsa
parent 44e3407a6b
commit b28cfe0db8
3 changed files with 36 additions and 0 deletions

31
test/dll.test.js Normal file
View File

@ -0,0 +1,31 @@
import test from 'ava'
import { resolve } from 'path'
import fs from 'fs'
import pify from 'pify'
import { Nuxt, Builder } from '../index.js'
const readFile = pify(fs.readFile)
const rootDir = resolve(__dirname, './fixtures/dll')
const dllDir = resolve(rootDir, '.cache/client-dll')
const checkCache = (lib) => {
return async (t) => {
const manifest = await readFile(resolve(dllDir, `./${lib}-manifest.json`), 'utf-8')
t.truthy(JSON.parse(manifest).name)
t.true(fs.existsSync(resolve(dllDir, `./${JSON.parse(manifest).name}.js`)))
}
}
test.before('Init Nuxt.js', async t => {
let config = require(resolve(rootDir, 'nuxt.config.js'))
config.rootDir = rootDir
config.dev = true
const nuxt = new Nuxt(config)
await new Builder(nuxt).build()
})
test('Check vue cache', checkCache('vue'))
test('Check vue-meta cache', checkCache('vue-meta'))
test('Check vue-router cache', checkCache('vue-router'))

5
test/fixtures/dll/nuxt.config.js vendored Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
build: {
dll: true
}
}

0
test/fixtures/dll/pages/index.vue vendored Normal file
View File