-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: fill out additional test targets (#97)
- Loading branch information
Showing
2 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,63 @@ | ||
import { join } from 'path' | ||
import { setupTest, get } from '@nuxt/test-utils' | ||
import { readFile } from 'fs-extra' | ||
import { setupTest, get, getContext } from '@nuxt/test-utils' | ||
|
||
describe('module', () => { | ||
describe('ssr: true, dev mode', () => { | ||
const rootDir = join(__dirname, '..', 'example') | ||
|
||
setupTest({ | ||
server: true, | ||
rootDir | ||
rootDir, | ||
config: { | ||
ssr: true, | ||
target: 'static' | ||
} | ||
}) | ||
|
||
test('render', async () => { | ||
const { body } = await get('/') | ||
expect(body).toContain('@nuxtjs/color-mode') | ||
expect(body).toContain('nuxt-color-mode-script') | ||
}) | ||
}) | ||
|
||
describe('ssr: true, target: server, prod mode', () => { | ||
const rootDir = join(__dirname, '..', 'example') | ||
|
||
setupTest({ | ||
server: true, | ||
build: true, | ||
rootDir, | ||
config: { | ||
ssr: true, | ||
target: 'server' | ||
} | ||
}) | ||
|
||
test('render', async () => { | ||
const { body } = await get('/') | ||
expect(body).toContain('nuxt-color-mode-script') | ||
}) | ||
}) | ||
|
||
describe('ssr: true, target: static, generated files', () => { | ||
const rootDir = join(__dirname, '..', 'example') | ||
|
||
setupTest({ | ||
generate: true, | ||
rootDir, | ||
config: { | ||
ssr: true, | ||
target: 'static' | ||
} | ||
}) | ||
|
||
test('generated file', async () => { | ||
const { nuxt } = getContext() | ||
const generateDir = nuxt.options.generate.dir | ||
const files = ['index.html', '200.html'] | ||
for (const file of files) { | ||
const contents = await readFile(join(generateDir, file), 'utf-8') | ||
expect(contents).toMatch('nuxt-color-mode-script') | ||
} | ||
}) | ||
}) |