mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 15:22:39 +00:00
Update test
This commit is contained in:
parent
2247097b64
commit
c5b5913402
@ -1,7 +1,7 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import rp from 'request-promise-native'
|
||||
const port = 4005
|
||||
const port = 4000
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
@ -38,5 +38,5 @@ test('/_nuxt/test.hot-update.json should returns empty html', async t => {
|
||||
// Close server and ask nuxt to stop listening to file changes
|
||||
test.after('Closing server and nuxt.js', t => {
|
||||
server.close()
|
||||
nuxt.close()
|
||||
nuxt.close(() => {})
|
||||
})
|
||||
|
@ -4,7 +4,7 @@ import http from 'http'
|
||||
import serveStatic from 'serve-static'
|
||||
import finalhandler from 'finalhandler'
|
||||
import rp from 'request-promise-native'
|
||||
const port = 4003
|
||||
const port = 4001
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
|
@ -3,7 +3,7 @@ import { resolve } from 'path'
|
||||
import rp from 'request-promise-native'
|
||||
import stdMocks from 'std-mocks'
|
||||
|
||||
const port = 4000
|
||||
const port = 4002
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
|
@ -1,6 +1,6 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
const port = 4001
|
||||
const port = 4003
|
||||
// const url = (route) => 'http://localhost:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
|
@ -4,7 +4,6 @@ import fs from 'fs'
|
||||
import pify from 'pify'
|
||||
const readFile = pify(fs.readFile)
|
||||
|
||||
// Init nuxt.js and create server listening on localhost:4000
|
||||
test.before('Init Nuxt.js', async t => {
|
||||
const Nuxt = require('../')
|
||||
const nuxt = await new Nuxt({
|
||||
|
@ -1,6 +1,6 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
const port = 4002
|
||||
const port = 4004
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
|
4
test/fixtures/module/modules/basic/index.js
vendored
4
test/fixtures/module/modules/basic/index.js
vendored
@ -8,12 +8,12 @@ module.exports = function basicModule (options, resolve) {
|
||||
this.addPlugin(path.resolve(__dirname, 'reverse.js'))
|
||||
|
||||
// Extend build
|
||||
this.extendBuild(({isClient, isServer}) => {
|
||||
this.extendBuild((config, { isClient, isServer }) => {
|
||||
// Do nothing!
|
||||
})
|
||||
|
||||
// Extend build again
|
||||
this.extendBuild(({isClient, isServer}) => {
|
||||
this.extendBuild((config, { isClient, isServer }) => {
|
||||
// Do nothing!
|
||||
})
|
||||
|
||||
|
@ -10,9 +10,11 @@ module.exports = function middlewareModule (options) {
|
||||
})
|
||||
// Add plain middleware
|
||||
this.addServerMiddleware((req, res, next) => {
|
||||
res.setHeader('x-nuxt', 'hello')
|
||||
next()
|
||||
})
|
||||
// Resolve
|
||||
// Add file middleware
|
||||
this.addServerMiddleware('~/modules/middleware/midd1')
|
||||
resolve()
|
||||
})
|
||||
}
|
||||
|
4
test/fixtures/module/modules/middleware/midd1.js
vendored
Normal file
4
test/fixtures/module/modules/middleware/midd1.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports = function (req, res, next) {
|
||||
res.setHeader('x-midd-1', 'ok')
|
||||
next()
|
||||
}
|
4
test/fixtures/module/modules/middleware/midd2.js
vendored
Normal file
4
test/fixtures/module/modules/middleware/midd2.js
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports = function (req, res, next) {
|
||||
res.setHeader('x-midd-2', 'ok')
|
||||
next()
|
||||
}
|
11
test/fixtures/module/modules/template/index.js
vendored
Normal file
11
test/fixtures/module/modules/template/index.js
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
const path = require('path')
|
||||
|
||||
module.exports = function () {
|
||||
// Disable parsing pages/
|
||||
this.nuxt.createRoutes = () => {}
|
||||
// Add /api endpoint
|
||||
this.addTemplate({
|
||||
fileName: 'router.js',
|
||||
src: path.resolve(this.nuxt.srcDir, 'router.js')
|
||||
})
|
||||
}
|
7
test/fixtures/module/nuxt.config.js
vendored
7
test/fixtures/module/nuxt.config.js
vendored
@ -1,6 +1,11 @@
|
||||
module.exports = {
|
||||
loading: true,
|
||||
modules: [
|
||||
'~modules/basic',
|
||||
'~modules/middleware'
|
||||
'~/modules/middleware',
|
||||
'./modules/template'
|
||||
],
|
||||
serverMiddleware: [
|
||||
'./modules/middleware/midd2'
|
||||
]
|
||||
}
|
||||
|
22
test/fixtures/module/router.js
vendored
Normal file
22
test/fixtures/module/router.js
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
|
||||
Vue.use(Router)
|
||||
|
||||
export function createRouter () {
|
||||
return new Router({
|
||||
mode: 'history',
|
||||
routes: [
|
||||
{
|
||||
path: "/",
|
||||
component: require('~/views/index.vue'),
|
||||
name: "index"
|
||||
},
|
||||
{
|
||||
path: "/about",
|
||||
component: require('~/views/about.vue'),
|
||||
name: "about"
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
6
test/fixtures/module/views/about.vue
vendored
Normal file
6
test/fixtures/module/views/about.vue
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>About page</h1>
|
||||
<nuxt-link to="/">Home page</nuxt-link>
|
||||
</div>
|
||||
</template>
|
@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div>
|
||||
<h1>{{ $reverseStr('NUXT') }}</h1>
|
||||
<nuxt-link to="/about">About page</nuxt-link>
|
||||
</div>
|
||||
</template>
|
3
test/fixtures/with-config/middleware/noop.js
vendored
Normal file
3
test/fixtures/with-config/middleware/noop.js
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export default function () {
|
||||
// NOOP!
|
||||
}
|
4
test/fixtures/with-config/nuxt.config.js
vendored
4
test/fixtures/with-config/nuxt.config.js
vendored
@ -1,6 +1,8 @@
|
||||
module.exports = {
|
||||
srcDir: __dirname,
|
||||
router: {
|
||||
base: '/test/',
|
||||
middleware: 'noop',
|
||||
extendRoutes (routes) {
|
||||
routes.push({
|
||||
name: 'about-bis',
|
||||
@ -9,7 +11,7 @@ module.exports = {
|
||||
})
|
||||
}
|
||||
},
|
||||
cache: true,
|
||||
transition: 'test',
|
||||
offline: true,
|
||||
plugins: [
|
||||
'~plugins/test.js',
|
||||
|
@ -2,7 +2,7 @@ import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
import rp from 'request-promise-native'
|
||||
|
||||
const port = 4000
|
||||
const port = 4005
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
|
@ -32,6 +32,7 @@ test('waitFor', async (t) => {
|
||||
let s = Date.now()
|
||||
await utils.waitFor(100)
|
||||
t.true(Date.now() - s >= 100)
|
||||
await utils.waitFor()
|
||||
})
|
||||
|
||||
test('urlJoin', t => {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import test from 'ava'
|
||||
import { resolve } from 'path'
|
||||
const port = 4004
|
||||
const port = 4006
|
||||
const url = (route) => 'http://localhost:' + port + route
|
||||
|
||||
let nuxt = null
|
||||
|
Loading…
Reference in New Issue
Block a user