-
Notifications
You must be signed in to change notification settings - Fork 22
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
Showing
4 changed files
with
226 additions
and
77 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
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,74 +1,78 @@ | ||
const consola = require('consola') | ||
const getPort = require('get-port') | ||
const { Nuxt, Builder } = require('nuxt-edge') | ||
|
||
const nuxtStable = require('nuxt') | ||
const nuxtEdge = require('nuxt-edge') | ||
jest.setTimeout(60 * 1000) | ||
|
||
let nuxt, port | ||
|
||
const url = route => 'http://localhost:' + port + route | ||
|
||
describe('nuxt-style-resources', () => { | ||
let log | ||
const setupNuxtFn = ({ Nuxt, Builder }) => async (config) => { | ||
const nuxt = new Nuxt(config) | ||
await new Builder(nuxt).build() | ||
port = await getPort() | ||
await nuxt.listen(port) | ||
|
||
beforeEach(() => { | ||
log = jest.fn() | ||
consola.clear().add({ log }) | ||
}) | ||
return nuxt | ||
} | ||
|
||
describe('scss', () => { | ||
test('properly import variables', async () => { | ||
nuxt = await setupNuxt(require('./fixture/sass/nuxt.config')) | ||
describe('nuxt-style-resources', () => { | ||
describe.each([['nuxt', nuxtStable], ['nuxt-edge', nuxtEdge]])('%s', (_, nuxtImpl) => { | ||
let log | ||
|
||
const window = await nuxt.server.renderAndGetWindow(url('/')) | ||
const headHtml = window.document.head.innerHTML | ||
expect(headHtml).toContain('.ymca{color:#333') | ||
}) | ||
const setupNuxt = setupNuxtFn(nuxtImpl) | ||
|
||
afterEach(async () => { | ||
if (nuxt) { | ||
await nuxt.close() | ||
} | ||
beforeEach(() => { | ||
log = jest.fn() | ||
consola.clear().add({ log }) | ||
}) | ||
}) | ||
describe('stylus', () => { | ||
test('properly import variables', async () => { | ||
nuxt = await setupNuxt(require('./fixture/stylus/nuxt.config')) | ||
|
||
const window = await nuxt.server.renderAndGetWindow(url('/')) | ||
const headHtml = window.document.head.innerHTML | ||
expect(headHtml).toContain('.ymca{color:#333') | ||
}) | ||
describe('scss', () => { | ||
test('properly import variables', async () => { | ||
nuxt = await setupNuxt(require('./fixture/sass/nuxt.config')) | ||
|
||
afterEach(async () => { | ||
if (nuxt) { | ||
await nuxt.close() | ||
} | ||
const window = await (nuxt.server || nuxt).renderAndGetWindow(url('/')) | ||
const headHtml = window.document.head.innerHTML | ||
expect(headHtml).toContain('.ymca{color:#333') | ||
}) | ||
|
||
afterEach(async () => { | ||
if (nuxt) { | ||
await nuxt.close() | ||
} | ||
}) | ||
}) | ||
}) | ||
describe('less', () => { | ||
test('properly import variables', async () => { | ||
nuxt = await setupNuxt(require('./fixture/less/nuxt.config')) | ||
describe('stylus', () => { | ||
test('properly import variables', async () => { | ||
nuxt = await setupNuxt(require('./fixture/stylus/nuxt.config')) | ||
|
||
const window = await (nuxt.server || nuxt).renderAndGetWindow(url('/')) | ||
const headHtml = window.document.head.innerHTML | ||
expect(headHtml).toContain('.ymca{color:#333') | ||
}) | ||
|
||
const window = await nuxt.server.renderAndGetWindow(url('/')) | ||
const headHtml = window.document.head.innerHTML | ||
expect(headHtml).toContain('h1{color:#0f0}') | ||
expect(headHtml).toContain('.ymca{color:#333') | ||
afterEach(async () => { | ||
if (nuxt) { | ||
await nuxt.close() | ||
} | ||
}) | ||
}) | ||
describe('less', () => { | ||
test('properly import variables', async () => { | ||
nuxt = await setupNuxt(require('./fixture/less/nuxt.config')) | ||
|
||
afterEach(async () => { | ||
if (nuxt) { | ||
await nuxt.close() | ||
} | ||
const window = await (nuxt.server || nuxt).renderAndGetWindow(url('/')) | ||
const headHtml = window.document.head.innerHTML | ||
expect(headHtml).toContain('h1{color:#0f0}') | ||
expect(headHtml).toContain('.ymca{color:#333') | ||
}) | ||
|
||
afterEach(async () => { | ||
if (nuxt) { | ||
await nuxt.close() | ||
} | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
const setupNuxt = async (config) => { | ||
const nuxt = new Nuxt(config) | ||
await new Builder(nuxt).build() | ||
port = await getPort() | ||
await nuxt.listen(port) | ||
|
||
return nuxt | ||
} |
Oops, something went wrong.