Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix axios dependency specification #72

Merged
merged 9 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ jobs:

strategy:
matrix:
node-version: [8.x, 14.x, 16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

node-version: [16, 18, 20]
axios-version: [0, 1]
env:
AXIOS_VERSION: ${{ matrix.axios-version }}
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
- name: Use Node.js ${{ matrix.node-version }} axios@${{ matrix.axios-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- run: npm run lint

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
Loading