Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Dec 14, 2020
1 parent 47afb06 commit 97c477f
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions test/axios.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ const testSuite = () => {
const call = addTemplate.mock.calls.find(args => args[0].src.includes('plugin.js'))
const options = call[0].options
const proto = options.https ? 'https' : 'http'
expect(options.baseURL.toString()).toBe(`${proto}://localhost:3000/api/test`)
expect(options.browserBaseURL.toString()).toBe('/api/test')
expect(options.baseURL.toString()).toBe(`${proto}://localhost:3000/api`)
expect(options.browserBaseURL.toString()).toBe('/api')
})

test('asyncData', async () => {
Expand Down Expand Up @@ -121,7 +121,7 @@ describe('module', () => {
describe('other options', () => {
beforeAll(async () => {
config.axios = {
prefix: '/api/test',
prefix: '/api',
proxy: {},
credentials: true,
https: true,
Expand All @@ -141,7 +141,7 @@ describe('other options', () => {
describe('browserBaseURL', () => {
beforeAll(async () => {
config.axios = {
browserBaseURL: '/api/test'
browserBaseURL: '/api'
}

await setupNuxt(config)
Expand All @@ -156,7 +156,7 @@ describe('browserBaseURL', () => {
const call = addTemplate.mock.calls.find(args => args[0].src.includes('plugin.js'))
const options = call[0].options
expect(options.baseURL.toString()).toBe('http://localhost:3000/')
expect(options.browserBaseURL.toString()).toBe('/api/test')
expect(options.browserBaseURL.toString()).toBe('/api')
})
})

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/fixture/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module.exports = {
{ handler: require('../../') }
],
serverMiddleware: {
'/api/test': '~/api/test',
'/api/echo': '~/api/echo',
'/api/cookie': '~/api/cookie'
},
axios: {
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/pages/asyncData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<script>
export default {
async asyncData ({ app }) {
const res = await app.$axios.$get('foo/bar')
const res = await app.$axios.$get('echo/foo/bar')
return {
res
}
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/pages/cancelToken.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
const source = this.$axios.CancelToken.source()
this.$axios
.$post(
'http://localhost:3000/api/test/foo/bar?delay=1000',
'http://localhost:3000/api/echo/foo/bar?delay=1000',
{ data: 'test' },
{
cancelToken: source.token
Expand Down
2 changes: 1 addition & 1 deletion test/fixture/pages/mounted.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
async mounted () {
// Request with full url becasue we are in JSDom env
this.res = await this.$axios.$get('http://localhost:3000/api/test/foo/bar')
this.res = await this.$axios.$get('http://localhost:3000/api/echo/foo/bar')
}
}
</script>
8 changes: 4 additions & 4 deletions test/fixture/pages/ssr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ export default {
},
computed: {
axiosSessionId () {
return this.$axios.defaults.defaultHeaders.SessionId
return this.$axios.defaults.headers.common.SessionId
},
axiosEncoding () {
return this.$axios.defaults.defaultHeaders['accept-encoding']
return this.$axios.defaults.headers.common['accept-encoding']
},
newInstanceSessionId () {
return this.newInstance.defaults.defaultHeaders.SessionId
return this.newInstance.defaults.headers.common.SessionId
},
newInstanceHeaders () {
return this.newInstance.defaults.defaultHeaders
return this.newInstance.defaults.headers.common
}
},
created () {
Expand Down

0 comments on commit 97c477f

Please sign in to comment.