Skip to content

Commit

Permalink
Fix axios multiversion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Borisov committed May 29, 2024
1 parent 587b70c commit 1dcfdb6
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 66 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ jobs:
matrix:
node-version: [8.x, 14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

axios-version: [0, 1]
env:
HAPI_VERSION: ${{ matrix.axios-version }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
- name: Use Node.js ${{ matrix.node-version }} axios@${{ matrix.axios-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
Expand Down
14 changes: 12 additions & 2 deletions __tests__/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
var axios = require('axios')
function requireAxios (version) {
switch (version) {
case '1':
return require('axios1/dist/browser/axios.cjs') // eslint-disable-line global-require
case '0':
default:
return require('axios0') // eslint-disable-line global-require
}
}

var axios = requireAxios(process.env.AXIOS_VERSION)
var sinon = require('sinon')

var axiosRateLimit = require('../src/index')
Expand Down Expand Up @@ -138,7 +148,7 @@ it('reject request if it was cancelled before executing', async function () {

expect(onSuccess.callCount).toBe(0)
expect(onFailure.callCount).toBe(1)
expect(onFailure.args).toEqual([[{ 'message': 'cancelled for testing' }]])
expect(onFailure.args.toString()).toContain('cancelled for testing')
})

it('not delay requests if requests are cancelled', async function () {
Expand Down
147 changes: 85 additions & 62 deletions package-lock.json

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

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"axios": ">=0.18.0"
},
"devDependencies": {
"axios0": "npm:axios@^0.28.1",
"axios1": "npm:axios@^1.0.0",
"@logux/eslint-config": "28.1.0",
"eslint": "^5.16.0",
"eslint-ci": "^1.0.0",
Expand Down

0 comments on commit 1dcfdb6

Please sign in to comment.