Nuxt/test/unit/nuxt.test.js
Jonas Galvez 3f1d634fb7 Consistent parens in arrow functions (#3630)
* Minor consistency enhancements

* Arrow parenthesis consistency

* Change linting rule

* Fix typo

* Update .eslintrc.js to only require parens for blocks

* Update style according to brace-only suggestion

* Remove --fix from lint

* Tweak no-loading time (failing test)

* Tweak no-loading time (failing test) (2)

* Tweak no-loading time (failing test) (3)

* Tweak no-loading time (failing test) (4)

* Tweak no-loading time (failing test) (5)
2018-08-06 02:12:44 +02:00

47 lines
1.3 KiB
JavaScript

import { resolve } from 'path'
import { loadFixture, getPort, Nuxt, Builder } from '../utils'
describe('nuxt', () => {
test('Nuxt.js Class', () => {
expect(typeof Nuxt).toBe('function')
})
test('Nuxt.js Instance', async () => {
const config = loadFixture('empty')
const nuxt = new Nuxt(config)
expect(typeof nuxt).toBe('object')
expect(nuxt.options.dev).toBe(false)
expect(typeof nuxt._ready.then).toBe('function')
await nuxt.ready()
expect(nuxt.initialized).toBe(true)
})
test('Fail to build when no pages/ directory but is in the parent', () => {
const nuxt = new Nuxt({
dev: false,
rootDir: resolve(__dirname, '..', 'fixtures', 'empty', 'pages')
})
return new Builder(nuxt).build().catch((err) => {
let s = String(err)
expect(s.includes('No `pages` directory found')).toBe(true)
expect(s.includes('Did you mean to run `nuxt` in the parent (`../`) directory?')).toBe(true)
})
})
test('Build with default page when no pages/ directory', async () => {
const nuxt = new Nuxt()
new Builder(nuxt).build()
const port = await getPort()
await nuxt.listen(port, 'localhost')
const { html } = await nuxt.renderRoute('/')
expect(html.includes('Universal Vue.js Applications')).toBe(true)
await nuxt.close()
})
})