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