Skip to content

Commit

Permalink
test: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sibbng committed Nov 10, 2021
1 parent dde3b12 commit 2faef4d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions packages/vite/src/node/__tests__/build.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,17 @@ describe('resolvePaths', () => {
const config = await resolveConfig({
build: {
rollupOptions: {
input: 'packages/noname/index.html'
input: 'index.html'
}
}
}, 'build', 'production')
const { input } = resolvePaths(config, config.build)

expect(input).toBe(resolve('packages/noname/index.html'))
expect(input).toBe(resolve('index.html'))
})

test('resolve build.rollupOptions.input[]', async () => {
const config = await resolveConfig({
root: 'packages/noname',
build: {
rollupOptions: {
input: ['index.html']
Expand All @@ -92,39 +91,44 @@ describe('resolvePaths', () => {
}, 'build', 'production')
const { input } = resolvePaths(config, config.build)

const resolved = resolve('packages/noname/index.html')
const resolved = resolve('index.html')

expect(input).toStrictEqual([resolved])
expect(config.build.rollupOptions.input).toStrictEqual([resolved])
})

test('resolve index.html', async () => {
const config = await resolveConfig({
root: 'packages/noname',
}, 'build', 'production')
const config = await resolveConfig({}, 'build', 'production')
const { input } = resolvePaths(config, config.build)

expect(input).toBe(resolve('packages/noname/index.html'))
expect(input).toBe(resolve('index.html'))
})

test('resolve build.outdir', async () => {
const config = await resolveConfig({ build: { outDir: 'packages/noname' } }, 'build', 'production')
const config = await resolveConfig({ build: { outDir: 'outDir' } }, 'build', 'production')
const { outDir } = resolvePaths(config, config.build)

expect(outDir).toBe(resolve('outDir'))
})

test('resolve default build.outdir', async () => {
const config = await resolveConfig({}, 'build', 'production')
const { outDir } = resolvePaths(config, config.build)

expect(outDir).toBe(resolve('packages/noname'))
expect(outDir).toBe(resolve('dist'))
})

test('resolve build.lib.entry', async () => {
const config = await resolveConfig({ build: { lib: { entry: 'packages/noname/index.html' } } }, 'build', 'production')
const config = await resolveConfig({ build: { lib: { entry: 'index.html' } } }, 'build', 'production')
const { input } = resolvePaths(config, config.build)

expect(input).toBe(resolve('packages/noname/index.html'))
expect(input).toBe(resolve('index.html'))
})

test('resolve build.ssr', async () => {
const config = await resolveConfig({ build: { ssr: 'packages/noname/ssr.ts' } }, 'build', 'production')
const config = await resolveConfig({ build: { ssr: 'ssr.ts' } }, 'build', 'production')
const { input } = resolvePaths(config, config.build)

expect(input).toBe(resolve('packages/noname/ssr.ts'))
expect(input).toBe(resolve('ssr.ts'))
})
})
Empty file.
Empty file.

0 comments on commit 2faef4d

Please sign in to comment.