Nuxt/test/unit/basic.config.defaults.test.js

41 lines
1.3 KiB
JavaScript
Raw Normal View History

import { resolve } from 'path'
2018-04-13 07:24:30 +00:00
import consola from 'consola'
import { Nuxt, getNuxtConfig, version } from '../utils'
2017-11-30 10:24:06 +00:00
2018-03-18 19:31:32 +00:00
describe('basic config defaults', () => {
test('Nuxt.version is same as package', () => {
expect(Nuxt.version).toBe(version)
})
test('modulesDir uses /node_modules as default if not set', () => {
const options = getNuxtConfig({})
2018-03-19 10:06:45 +00:00
const currentNodeModulesDir = resolve(__dirname, '..', '..', 'node_modules')
2018-03-18 19:31:32 +00:00
expect(options.modulesDir.includes(currentNodeModulesDir)).toBe(true)
})
2018-04-13 07:24:30 +00:00
test('vendor has been deprecated', () => {
const options = getNuxtConfig({
2018-04-13 07:24:30 +00:00
build: { vendor: 'vue' }
})
expect(options.build.vendor).toBeUndefined()
expect(consola.warn).toHaveBeenCalledWith('vendor has been deprecated due to webpack4 optimization')
})
test('globalName uses nuxt as default if not set', () => {
const options = getNuxtConfig({})
expect(options.globalName).toEqual('nuxt')
})
test('globalName uses nuxt as default if set to something other than only letters', () => {
let options = getNuxtConfig({ globalName: '12foo4' })
expect(options.globalName).toEqual('nuxt')
options = getNuxtConfig({ globalName: 'foo bar' })
expect(options.globalName).toEqual('nuxt')
options = getNuxtConfig({ globalName: 'foo?' })
expect(options.globalName).toEqual('nuxt')
})
})