Skip to content

Commit

Permalink
build(kitsu)(deps): update dependency axios to v0.28.0
Browse files Browse the repository at this point in the history
  • Loading branch information
justin-tay committed Feb 27, 2024
1 parent 33973e6 commit bf41b9e
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 21 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"@babel/core": "~7.23.0",
"@babel/preset-env": "~7.23.0",
"@rollup/plugin-babel": "~6.0.0",
"axios": "~0.27.0",
"axios": "~0.28.0",
"axios-mock-adapter": "~1.22.0",
"babel-jest": "~29.7.0",
"browserslist": "~4.22.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/kitsu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@
"build": "yarn rollup"
},
"dependencies": {
"axios": "^0.27.0",
"axios": "^0.28.0",
"kitsu-core": "^10.1.2",
"pluralize": "^8.0.0"
},
"size-limit": [
{
"path": "./dist/index.js",
"limit": "13 kb",
"limit": "14 kb",
"brotli": true
},
{
"path": "./dist/index.mjs",
"limit": "13 kb",
"limit": "14 kb",
"brotli": true
}
],
Expand Down
15 changes: 15 additions & 0 deletions packages/kitsu/src/delete.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ describe('kitsu', () => {
expect(api.axios.delete).toHaveBeenCalledWith('anime/1', expect.objectContaining({ withCredentials: true }))
})

it('sets encode and serialize', async () => {
expect.assertions(4)
const api = new Kitsu({ headers: { init: true } })
mock.onDelete('/anime/1').reply(config => {
expect(config.paramsSerializer.encode).toBeDefined()
expect(config.paramsSerializer.serialize).toBeDefined()
expect(config.paramsSerializer.encode('[]')).toBe('%5B%5D')
return [ 200, { data: [] } ]
})
const response = await api.delete('anime', 1)
await expect(await response).toEqual({
data: []
})
})

it('sends and recieves headers', async () => {
expect.assertions(2)
const api = new Kitsu({ headers: { Authorization: true } })
Expand Down
15 changes: 15 additions & 0 deletions packages/kitsu/src/get.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ describe('kitsu', () => {
expect(api.axios.get).toHaveBeenCalledWith('anime', expect.objectContaining({ withCredentials: true }))
})

it('sets encode and serialize', async () => {
expect.assertions(4)
const api = new Kitsu({ headers: { init: true } })
mock.onGet('/anime').reply(config => {
expect(config.paramsSerializer.encode).toBeDefined()
expect(config.paramsSerializer.serialize).toBeDefined()
expect(config.paramsSerializer.encode('[]')).toBe('%5B%5D')
return [ 200, { data: [] } ]
})
const response = await api.get('anime')
await expect(await response).toEqual({
data: []
})
})

it('sends and recieves headers', async () => {
expect.assertions(2)
const api = new Kitsu({ headers: { init: true } })
Expand Down
17 changes: 6 additions & 11 deletions packages/kitsu/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,11 @@ export default class Kitsu {
},
...options.axiosOptions
})

this.fetch = this.get
this.update = this.patch
this.create = this.post
this.remove = this.delete

this.paramsSerializer = { serialize: /* istanbul ignore next */ p => this.query(p), encode: val => encodeURI(val) }
/**
* Axios Interceptors (alias of `axios.interceptors`)
*
Expand Down Expand Up @@ -235,7 +234,7 @@ export default class Kitsu {
const { data, headers: responseHeaders } = await this.axios.get(url, {
headers,
params,
paramsSerializer: /* istanbul ignore next */ p => this.query(p),
paramsSerializer: this.paramsSerializer,
...config.axiosOptions
})

Expand Down Expand Up @@ -296,13 +295,9 @@ export default class Kitsu {
fullURL,
serialData,
{
headers,
params,
paramsSerializer: /* istanbul ignore next */ p => this.query(p),
...config.axiosOptions
headers, params, paramsSerializer: this.paramsSerializer, ...config.axiosOptions
}
)

return responseHeaders ? { ...deserialise(data), ...{ headers: responseHeaders } } : deserialise(data)
} catch (E) {
throw error(E)
Expand Down Expand Up @@ -359,7 +354,7 @@ export default class Kitsu {
{
headers,
params,
paramsSerializer: /* istanbul ignore next */ p => this.query(p),
paramsSerializer: this.paramsSerializer,
...config.axiosOptions
}
)
Expand Down Expand Up @@ -414,7 +409,7 @@ export default class Kitsu {
}),
headers,
params,
paramsSerializer: /* istanbul ignore next */ p => this.query(p),
paramsSerializer: this.paramsSerializer,
...config.axiosOptions
})

Expand Down Expand Up @@ -524,7 +519,7 @@ export default class Kitsu {
}),
headers: { ...this.headers, ...headers },
params,
paramsSerializer: /* istanbul ignore next */ p => this.query(p),
paramsSerializer: this.paramsSerializer,
...axiosOptions
})

Expand Down
15 changes: 15 additions & 0 deletions packages/kitsu/src/patch.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ describe('kitsu', () => {
expect(api.axios.patch).toHaveBeenCalledWith('anime/1', { data: { id: '1', type: 'anime' } }, expect.objectContaining({ withCredentials: true }))
})

it('sets encode and serialize', async () => {
expect.assertions(4)
const api = new Kitsu({ headers: { init: true } })
mock.onPatch('/anime/1').reply(config => {
expect(config.paramsSerializer.encode).toBeDefined()
expect(config.paramsSerializer.serialize).toBeDefined()
expect(config.paramsSerializer.encode('[]')).toBe('%5B%5D')
return [ 200, { data: [] } ]
})
const response = await api.patch('anime', { id: '1', type: 'anime' })
await expect(await response).toEqual({
data: []
})
})

it('sends and receieves headers', async () => {
expect.assertions(2)
const api = new Kitsu({ headers: { Authorization: true } })
Expand Down
15 changes: 15 additions & 0 deletions packages/kitsu/src/post.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ describe('kitsu', () => {
expect(api.axios.post).toHaveBeenCalledWith('anime', { data: { id: '1', type: 'anime' } }, expect.objectContaining({ withCredentials: true }))
})

it('sets encode and serialize', async () => {
expect.assertions(4)
const api = new Kitsu({ headers: { init: true } })
mock.onPost('/anime').reply(config => {
expect(config.paramsSerializer.encode).toBeDefined()
expect(config.paramsSerializer.serialize).toBeDefined()
expect(config.paramsSerializer.encode('[]')).toBe('%5B%5D')
return [ 200, { data: [] } ]
})
const response = await api.post('anime', { id: '1', type: 'anime' })
await expect(await response).toEqual({
data: []
})
})

it('sends and recieves headers', async () => {
expect.assertions(2)
const api = new Kitsu({ headers: { Authorization: true } })
Expand Down
18 changes: 18 additions & 0 deletions packages/kitsu/src/request.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,24 @@ describe('kitsu', () => {
expect(api.axios.request).toHaveBeenCalledWith(expect.objectContaining({ withCredentials: true }))
})

it('sets encode and serialize', async () => {
expect.assertions(4)
const api = new Kitsu({ headers: { init: true } })
mock.onGet('/anime/1').reply(config => {
expect(config.paramsSerializer.encode).toBeDefined()
expect(config.paramsSerializer.serialize).toBeDefined()
expect(config.paramsSerializer.encode('[]')).toBe('%5B%5D')
return [ 200, { data: [] } ]
})
const response = await api.request({
method: 'GET',
url: 'anime/1'
})
await expect(await response).toEqual({
data: []
})
})

it('sends and receives headers', async () => {
expect.assertions(2)
const api = new Kitsu({ headers: { Authorization: true } })
Expand Down
18 changes: 12 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3074,13 +3074,14 @@ axios-mock-adapter@~1.22.0:
fast-deep-equal "^3.1.3"
is-buffer "^2.0.5"

axios@^0.27.0, axios@~0.27.0:
version "0.27.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972"
integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==
axios@^0.28.0, axios@~0.28.0:
version "0.28.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.28.0.tgz#801a4d991d0404961bccef46800e1170f8278c89"
integrity sha512-Tu7NYoGY4Yoc7I+Npf9HhUMtEEpV7ZiLH9yndTCoNhcpBH0kwcvFbzYN9/u5QKI5A6uefjsNNWaz5olJVYS62Q==
dependencies:
follow-redirects "^1.14.9"
follow-redirects "^1.15.0"
form-data "^4.0.0"
proxy-from-env "^1.1.0"

babel-jest@^29.7.0, babel-jest@~29.7.0:
version "29.7.0"
Expand Down Expand Up @@ -4996,7 +4997,7 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"

follow-redirects@^1.14.9:
follow-redirects@^1.15.0:
version "1.15.5"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.5.tgz#54d4d6d062c0fa7d9d17feb008461550e3ba8020"
integrity sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==
Expand Down Expand Up @@ -8703,6 +8704,11 @@ protoduck@^5.0.1:
dependencies:
genfun "^5.0.0"

proxy-from-env@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2"
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==

psl@^1.1.28, psl@^1.1.33:
version "1.9.0"
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"
Expand Down

0 comments on commit bf41b9e

Please sign in to comment.