Skip to content

Commit

Permalink
test: remove unnecessary generate (#6301)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo authored Aug 25, 2019
1 parent de71eee commit c14bb35
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 124 deletions.
12 changes: 11 additions & 1 deletion packages/config/test/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,21 @@ describe('config: options', () => {
expect(pageTransition.appear).toEqual(true)
})

test('should return 404.html as default generate.fallback', () => {
test('should return 200.html as default generate.fallback', () => {
const { generate: { fallback } } = getNuxtConfig({})
expect(fallback).toEqual('200.html')
})

test('should return 404.html when generate.fallback is true', () => {
const { generate: { fallback } } = getNuxtConfig({ generate: { fallback: true } })
expect(fallback).toEqual('404.html')
})

test('should return fallback html when generate.fallback is string', () => {
const { generate: { fallback } } = getNuxtConfig({ generate: { fallback: 'fallback.html' } })
expect(fallback).toEqual('fallback.html')
})

test('should disable parallel if extractCSS is enabled', () => {
const { build: { parallel } } = getNuxtConfig({ build: { extractCSS: true, parallel: true } })
expect(parallel).toEqual(false)
Expand Down
1 change: 1 addition & 0 deletions packages/generator/test/generator.route.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('generator: generate route', () => {
const nuxt = createNuxt()
nuxt.options.build.html = { minify: false }
nuxt.options.generate.minify = undefined
nuxt.options.generate.subFolders = false
const generator = new Generator(nuxt)
path.join.mockClear()

Expand Down
3 changes: 1 addition & 2 deletions test/fixtures/basic/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export default {
'/тест雨',
{ route: '/users/3', payload: { id: 3000 } }
],
interval: 200,
subFolders: true
interval: 200
},
head () {
return {
Expand Down
22 changes: 8 additions & 14 deletions test/unit/basic.generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,20 +204,6 @@ describe('basic generate', () => {
})
})

test('nuxt re-generating with no subfolders', async () => {
generator.nuxt.options.generate.subFolders = false
await expect(generator.generate({ build: false })).resolves.toBeTruthy()
})

test('/users/1.html', async () => {
const html = await rp(url('/users/1.html'))
expect(html).toContain('<h1>User: 1</h1>')
expect(existsSync(resolve(distDir, 'users/1.html'))).toBe(true)
expect(
existsSync(resolve(distDir, 'users/1/index.html'))
).toBe(false)
})

test('/-ignored', async () => {
await expect(rp(url('/-ignored'))).rejects.toMatchObject({
statusCode: 404,
Expand All @@ -236,6 +222,14 @@ describe('basic generate', () => {
})
})

test('creates /200.html as fallback', async () => {
const html = await rp(url('/200.html'))
expect(html.includes('<h1>Index page</h1>')).toBe(false)
expect(html.includes('data-server-rendered')).toBe(false)
expect(existsSync(resolve(distDir, '200.html'))).toBe(true)
expect(existsSync(resolve(distDir, '404.html'))).toBe(false)
})

// Close server and ask nuxt to stop listening to file changes
afterAll(async () => {
await server.close()
Expand Down
107 changes: 0 additions & 107 deletions test/unit/fallback.generate.test.js

This file was deleted.

0 comments on commit c14bb35

Please sign in to comment.