mirror of https://github.com/sundowndev/http.git
misc: update to nuxt 1.x
parent
f71fa8d2c4
commit
9b0834898d
|
@ -39,7 +39,7 @@
|
||||||
"whatwg-url": "^6.4.0"
|
"whatwg-url": "^6.4.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"nuxt": "^1.0.0-rc11",
|
"nuxt": "^1.1.1",
|
||||||
"codecov": "^3.0.0",
|
"codecov": "^3.0.0",
|
||||||
"eslint": "^4.14.0",
|
"eslint": "^4.14.0",
|
||||||
"eslint-config-standard": "^11.0.0-beta.0",
|
"eslint-config-standard": "^11.0.0-beta.0",
|
||||||
|
|
|
@ -13,11 +13,13 @@ describe('axios module', () => {
|
||||||
let addTemplate
|
let addTemplate
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
config.modules.unshift(function () {
|
|
||||||
addTemplate = this.addTemplate = jest.fn(this.addTemplate)
|
|
||||||
})
|
|
||||||
|
|
||||||
nuxt = new Nuxt(config)
|
nuxt = new Nuxt(config)
|
||||||
|
|
||||||
|
// Spy addTemplate
|
||||||
|
addTemplate = nuxt.moduleContainer.addTemplate = jest.fn(
|
||||||
|
nuxt.moduleContainer.addTemplate
|
||||||
|
)
|
||||||
|
|
||||||
await new Builder(nuxt).build()
|
await new Builder(nuxt).build()
|
||||||
await nuxt.listen(process.env.PORT)
|
await nuxt.listen(process.env.PORT)
|
||||||
})
|
})
|
||||||
|
@ -27,10 +29,14 @@ describe('axios module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('baseURL', () => {
|
test('baseURL', () => {
|
||||||
let call = addTemplate.mock.calls.find(args => args[0].src.includes('plugin.template.js'))
|
expect(addTemplate).toBeDefined()
|
||||||
expect(call).toBeDefined()
|
let call = addTemplate.mock.calls.find(args =>
|
||||||
|
args[0].src.includes('plugin.template.js')
|
||||||
|
)
|
||||||
let options = call[0].options
|
let options = call[0].options
|
||||||
expect(options.baseURL.toString()).toBe(`http://localhost:${process.env.PORT}/test_api`)
|
expect(options.baseURL.toString()).toBe(
|
||||||
|
`http://localhost:${process.env.PORT}/test_api`
|
||||||
|
)
|
||||||
expect(options.browserBaseURL.toString()).toBe('/test_api')
|
expect(options.browserBaseURL.toString()).toBe('/test_api')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -56,10 +62,12 @@ describe('axios module', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
test('ssr', async () => {
|
test('ssr', async () => {
|
||||||
const makeReq = (login) => axios.get(url('/ssr' + (login ? '?login' : '')))
|
const makeReq = login =>
|
||||||
.then(r => r.data)
|
axios
|
||||||
.then(h => /session-[0-9]+/.exec(h))
|
.get(url('/ssr' + (login ? '?login' : '')))
|
||||||
.then(m => (m && m[0]) ? m[0] : null)
|
.then(r => r.data)
|
||||||
|
.then(h => /session-[0-9]+/.exec(h))
|
||||||
|
.then(m => (m && m[0] ? m[0] : null))
|
||||||
|
|
||||||
let a = await makeReq()
|
let a = await makeReq()
|
||||||
let b = await makeReq(true)
|
let b = await makeReq(true)
|
||||||
|
|
|
@ -1,23 +1,17 @@
|
||||||
const axiosModule = require('../..')
|
const { resolve } = require('path')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
rootDir: resolve(__dirname, '../..'),
|
||||||
srcDir: __dirname,
|
srcDir: __dirname,
|
||||||
dev: false,
|
dev: false,
|
||||||
render: {
|
render: {
|
||||||
resourceHints: false
|
resourceHints: false
|
||||||
},
|
},
|
||||||
modules: [
|
modules: ['@@'],
|
||||||
axiosModule
|
serverMiddleware: ['~/api.js'],
|
||||||
],
|
|
||||||
serverMiddleware: [
|
|
||||||
'~/api'
|
|
||||||
],
|
|
||||||
axios: {
|
axios: {
|
||||||
// Defaults
|
baseURL: `http://localhost:${process.env.PORT || 3000}/test_api`,
|
||||||
baseURL: `http://localhost:${process.env.PORT}/test_api`,
|
init (axios) {},
|
||||||
init (axios) {
|
|
||||||
|
|
||||||
},
|
|
||||||
responseInterceptor: (response, { store }) => {
|
responseInterceptor: (response, { store }) => {
|
||||||
/* eslint-disable no-console */
|
/* eslint-disable no-console */
|
||||||
console.log('YAY')
|
console.log('YAY')
|
||||||
|
|
Loading…
Reference in New Issue