Skip to content

Commit

Permalink
Pin axios peer dependency to <1.2.0 (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
emileber authored Aug 9, 2023
1 parent 7972886 commit 024a39f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
"http"
],
"peerDependencies": {
"axios": ">= 0.17.1"
"axios": ">=0.17.1 <1.2.0"
},
"devDependencies": {
"@babel/preset-env": "^7.3.4",
"axios": "^1.4.0",
"axios": "^1.1.3",
"axios-mock-adapter": "^1.21.5",
"codecov": "^3.2.0",
"cross-env": "^7.0.3",
Expand Down
21 changes: 21 additions & 0 deletions test/specs/service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@ describe('Middleware service', () => {
mock.restore();
});

it('works with the global axios instance', () => {
expect.assertions(3);

const axiosAdapter = axios.defaults.adapter;
const globalMock = new MockAdapter(axios);
const globalService = new Service(axios);

globalMock.onAny().reply((config) => [200, config.param]);

return axios().then(() => {
expect(axios.defaults.adapter).not.toBe(axiosAdapter);
expect(axios.defaults.adapter).toBeInstanceOf(Function);

globalService.unsetHttp();
globalMock.restore();

expect(axios.defaults.adapter).toBe(axiosAdapter);
});
});

it('throws when adding the same middleware instance', () => {
const middleware = {};

Expand Down Expand Up @@ -70,6 +90,7 @@ describe('Middleware service', () => {

it('can catch current request promise', () => {
expect.assertions(1);

service.register({
onSync(promise) {
expect(promise).toBeInstanceOf(Promise);
Expand Down

0 comments on commit 024a39f

Please sign in to comment.