2023-02-02 15:13:55 +00:00
|
|
|
import { normalize, resolve } from 'upath'
|
2018-04-13 07:24:30 +00:00
|
|
|
import consola from 'consola'
|
2018-12-10 21:34:41 +00:00
|
|
|
import Glob from 'glob'
|
|
|
|
import pify from 'pify'
|
2018-04-13 07:24:30 +00:00
|
|
|
|
2018-10-30 20:42:53 +00:00
|
|
|
import { Nuxt, getNuxtConfig, version } from '../utils'
|
2017-11-30 10:24:06 +00:00
|
|
|
|
2018-12-10 21:34:41 +00:00
|
|
|
const glob = pify(Glob)
|
|
|
|
|
2018-03-18 19:31:32 +00:00
|
|
|
describe('basic config defaults', () => {
|
|
|
|
test('Nuxt.version is same as package', () => {
|
|
|
|
expect(Nuxt.version).toBe(version)
|
|
|
|
})
|
2017-11-27 17:00:23 +00:00
|
|
|
|
2018-08-10 07:41:23 +00:00
|
|
|
test('modulesDir uses /node_modules as default if not set', () => {
|
2018-10-30 20:42:53 +00:00
|
|
|
const options = getNuxtConfig({})
|
2018-03-19 10:06:45 +00:00
|
|
|
const currentNodeModulesDir = resolve(__dirname, '..', '..', 'node_modules')
|
2023-02-02 15:13:55 +00:00
|
|
|
expect(options.modulesDir.map(d => normalize(d))).toContain(currentNodeModulesDir)
|
2018-03-18 19:31:32 +00:00
|
|
|
})
|
2018-04-13 07:24:30 +00:00
|
|
|
|
2018-12-10 21:34:41 +00:00
|
|
|
test('client source map not generated', async () => {
|
|
|
|
const mapFiles = await glob(resolve(__dirname, '..', 'fixtures/basic/.nuxt/dist/client/*.js.map'))
|
|
|
|
expect(mapFiles.length).toEqual(0)
|
|
|
|
})
|
|
|
|
|
2018-08-10 07:41:23 +00:00
|
|
|
test('vendor has been deprecated', () => {
|
2018-10-30 20:42:53 +00:00
|
|
|
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')
|
|
|
|
})
|
2018-10-09 12:07:23 +00:00
|
|
|
|
|
|
|
test('globalName uses nuxt as default if not set', () => {
|
2018-10-30 20:42:53 +00:00
|
|
|
const options = getNuxtConfig({})
|
2018-10-09 12:07:23 +00:00
|
|
|
expect(options.globalName).toEqual('nuxt')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('globalName uses nuxt as default if set to something other than only letters', () => {
|
2018-10-30 20:42:53 +00:00
|
|
|
let options = getNuxtConfig({ globalName: '12foo4' })
|
2018-10-09 12:07:23 +00:00
|
|
|
expect(options.globalName).toEqual('nuxt')
|
|
|
|
|
2018-10-30 20:42:53 +00:00
|
|
|
options = getNuxtConfig({ globalName: 'foo bar' })
|
2018-10-09 12:07:23 +00:00
|
|
|
expect(options.globalName).toEqual('nuxt')
|
|
|
|
|
2018-10-30 20:42:53 +00:00
|
|
|
options = getNuxtConfig({ globalName: 'foo?' })
|
2018-10-09 12:07:23 +00:00
|
|
|
expect(options.globalName).toEqual('nuxt')
|
|
|
|
})
|
2018-11-08 20:47:53 +00:00
|
|
|
|
|
|
|
test('@nuxtjs/babel-preset-app has been deprecated', () => {
|
|
|
|
let options = getNuxtConfig({
|
|
|
|
build: {
|
|
|
|
babel: {
|
|
|
|
presets: ['@nuxtjs/babel-preset-app']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
expect(options.build.babel.presets).toEqual(['@nuxt/babel-preset-app'])
|
|
|
|
expect(consola.warn).toHaveBeenCalledWith('@nuxtjs/babel-preset-app has been deprecated, please use @nuxt/babel-preset-app.')
|
|
|
|
|
|
|
|
consola.warn.mockClear()
|
|
|
|
|
|
|
|
options = getNuxtConfig({
|
|
|
|
build: {
|
|
|
|
babel: {
|
|
|
|
presets: [['@nuxtjs/babel-preset-app']]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
expect(options.build.babel.presets).toEqual([['@nuxt/babel-preset-app']])
|
|
|
|
expect(consola.warn).toHaveBeenCalledWith('@nuxtjs/babel-preset-app has been deprecated, please use @nuxt/babel-preset-app.')
|
|
|
|
})
|
2017-11-27 17:00:23 +00:00
|
|
|
})
|