Nuxt/packages/generator/test/__utils__/index.js
pooya parsa dec8f99fc3
feat: support plug-and-play, typescript runtime and native modules (#8389)
Co-authored-by: Clark Du <clark.duxin@gmail.com>
2020-12-22 18:07:50 +01:00

28 lines
694 B
JavaScript

import { resolve } from 'path'
import env from 'std-env'
const isWin = env.windows
const rootDir = isWin ? 'C:\\nuxt' : '/var/nuxt'
export const createNuxt = () => ({
ready: jest.fn(),
callHook: jest.fn(),
server: {
renderRoute: jest.fn(() => ({ html: 'rendered html' }))
},
options: {
mode: 'universal',
srcDir: resolve(rootDir, 'src'),
buildDir: resolve(rootDir, 'build'),
generate: { dir: resolve(rootDir, 'generate') },
build: { publicPath: '__public' },
dir: { static: resolve(rootDir, 'static') },
render: {}
}
})
export function hookCalls (nuxt, name) {
return nuxt.callHook.mock.calls.filter(c => c[0] === name).map(c => c.splice(1))
}