-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7101ab7
commit b260a15
Showing
4 changed files
with
104 additions
and
74 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
jest.setTimeout(60000) | ||
|
||
const { Nuxt, Builder } = require('nuxt-edge') | ||
const request = require('request-promise-native') | ||
const getPort = require('get-port') | ||
|
||
const config = require('./fixture/nuxt.config') | ||
config.dev = true | ||
|
||
let nuxt, port | ||
|
||
const url = path => `http://localhost:${port}${path}` | ||
const get = path => request(url(path)) | ||
|
||
describe('dev', () => { | ||
beforeAll(async () => { | ||
nuxt = new Nuxt(config) | ||
await nuxt.ready() | ||
await new Builder(nuxt).build() | ||
port = await getPort() | ||
await nuxt.listen(port) | ||
}) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('render', async () => { | ||
const html = await get('/') | ||
expect(html).toContain('Works!') | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
jest.setTimeout(60000) | ||
|
||
const { Nuxt, Builder } = require('nuxt-edge') | ||
const request = require('request-promise-native') | ||
const getPort = require('get-port') | ||
|
||
const config = require('./fixture/nuxt.config') | ||
config.dev = false | ||
|
||
let nuxt, port | ||
|
||
const url = path => `http://localhost:${port}${path}` | ||
const get = path => request(url(path)) | ||
|
||
describe('prod', () => { | ||
beforeAll(async () => { | ||
nuxt = new Nuxt(config) | ||
await nuxt.ready() | ||
await new Builder(nuxt).build() | ||
port = await getPort() | ||
await nuxt.listen(port) | ||
}) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('render', async () => { | ||
const html = await get('/') | ||
expect(html).toContain('Works!') | ||
}) | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
jest.setTimeout(60000) | ||
|
||
const { Nuxt } = require('nuxt-edge') | ||
const config = require('./fixture/nuxt.config') | ||
const logger = require('@/logger') | ||
const { moduleExists } = require('@/utils') | ||
|
||
logger.mockTypes(() => jest.fn()) | ||
|
||
jest.mock('@/utils', () => ({ | ||
moduleExists: jest.fn() | ||
})) | ||
|
||
let nuxt | ||
|
||
describe('warn', () => { | ||
beforeAll(async () => { | ||
moduleExists.mockImplementation(() => false) | ||
|
||
nuxt = new Nuxt(config) | ||
await nuxt.ready() | ||
}) | ||
|
||
beforeEach(() => { | ||
logger.clear() | ||
}) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('should warn if not found the `stylelint` dependency', () => { | ||
expect(moduleExists).toBeCalledWith('stylelint') | ||
expect(moduleExists).toHaveReturnedWith(false) | ||
expect(logger.warn).toHaveBeenCalledWith( | ||
'The dependency `stylelint` not found.', | ||
'Please run `yarn add stylelint --dev` or `npm install stylelint --save-dev`' | ||
) | ||
}) | ||
}) |