/
build.test.js
32 lines (29 loc) · 1.35 KB
/
build.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import buildConfig from '../../src/config/build'
describe('config: build', () => {
test('should return dev filenames', () => {
const { filenames } = buildConfig()
const env = { isDev: true }
expect(filenames.app(env)).toEqual('[name].js')
expect(filenames.chunk(env)).toEqual('[name].js')
expect(filenames.css(env)).toEqual('[name].css')
expect(filenames.img(env)).toEqual('[path][name].[ext]')
expect(filenames.font(env)).toEqual('[path][name].[ext]')
expect(filenames.video(env)).toEqual('[path][name].[ext]')
})
test('should return prod filenames', () => {
const { filenames } = buildConfig()
const env = { isDev: false }
expect(filenames.app(env)).toEqual('[name].[contenthash:7].js')
expect(filenames.chunk(env)).toEqual('[name].[contenthash:7].js')
expect(filenames.css(env)).toEqual('[name].[contenthash:7].css')
expect(filenames.img(env)).toEqual('img/[name].[contenthash:7].[ext]')
expect(filenames.font(env)).toEqual('fonts/[name].[contenthash:7].[ext]')
expect(filenames.video(env)).toEqual('videos/[name].[contenthash:7].[ext]')
})
test('should return modern filenames', () => {
const { filenames } = buildConfig()
const env = { isDev: true, isModern: true }
expect(filenames.app(env)).toEqual('modern-[name].js')
expect(filenames.chunk(env)).toEqual('modern-[name].js')
})
})