mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-06 21:10:38 +00:00
test: add test for open-in-editor
This commit is contained in:
parent
45bba51e96
commit
72b31a217f
36
test/debug.test.js
Normal file
36
test/debug.test.js
Normal file
@ -0,0 +1,36 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import rp from 'request-promise-native'
|
||||
import { Nuxt, Builder } from '../index.js'
|
||||
|
||||
const port = 4009
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
|
||||
// Init nuxt.js and create server listening on localhost:4000
|
||||
test.before('Init Nuxt.js', async t => {
|
||||
const rootDir = resolve(__dirname, 'fixtures/debug')
|
||||
let config = require(resolve(rootDir, 'nuxt.config.js'))
|
||||
config.rootDir = rootDir
|
||||
config.dev = false
|
||||
nuxt = new Nuxt(config)
|
||||
await new Builder(nuxt).build()
|
||||
|
||||
await nuxt.listen(port, 'localhost')
|
||||
})
|
||||
|
||||
test('Check /test/_open (open-in-editor)', async t => {
|
||||
const { body } = await rp(url('/test/_open?file=pages/index.vue'), { resolveWithFullResponse: true })
|
||||
t.is(body, 'opened in editor!')
|
||||
})
|
||||
|
||||
test('Check /test/_open with error (open-in-editor)', async t => {
|
||||
const { body } = await rp(url('/test/_open?file='), { resolveWithFullResponse: true })
|
||||
t.is(body, 'File is not specified')
|
||||
})
|
||||
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
test.after('Closing server and nuxt.js', t => {
|
||||
nuxt.close()
|
||||
})
|
10
test/fixtures/debug/nuxt.config.js
vendored
Normal file
10
test/fixtures/debug/nuxt.config.js
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
module.exports = {
|
||||
router: {
|
||||
base: '/test/'
|
||||
},
|
||||
debug: true,
|
||||
editor: {
|
||||
cmd: 'echo',
|
||||
pattern: ''
|
||||
}
|
||||
}
|
0
test/fixtures/debug/pages/index.vue
vendored
Normal file
0
test/fixtures/debug/pages/index.vue
vendored
Normal file
Loading…
Reference in New Issue
Block a user