generated from sonofmagic/monorepo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.test.ts
47 lines (42 loc) · 1.36 KB
/
index.test.ts
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { resolve } from 'pathe'
import { configName } from '@/constants'
import { getDefaultMangleUserConfig, getDefaultUserConfig } from '@/defaults'
import { getConfig, initConfig } from '@/index'
import { deleteAsync } from 'del'
import { existsSync } from 'fs-extra'
import { fixturesRoot } from './utils'
describe('config', () => {
it('0.default', async () => {
const cwd = resolve(fixturesRoot, './config/0.default')
const configPath = resolve(cwd, `${configName}.config.ts`)
if (existsSync(configPath)) {
await deleteAsync(configPath)
}
await initConfig(cwd)
expect(existsSync(configPath)).toBe(true)
const { config } = await getConfig(cwd)
expect(config).toEqual(getDefaultUserConfig())
})
it('1.change-options', async () => {
const cwd = resolve(fixturesRoot, './config/1.change-options')
const { config } = await getConfig(cwd)
expect(config).toEqual({
patch: {
output: {
filename: 'xxx/yyy/zzz.json',
loose: false,
removeUniversalSelector: false,
},
tailwindcss: {
cwd: 'aaa/bbb/cc',
},
},
mangle: getDefaultMangleUserConfig(),
})
})
it('2.mangle-options', async () => {
const cwd = resolve(fixturesRoot, './config/2.mangle-options')
const { config } = await getConfig(cwd)
expect(config).toMatchSnapshot()
})
})