Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/npm_and_yarn/http-proxy-agent-7…
Browse files Browse the repository at this point in the history
….0.0
  • Loading branch information
shazron authored Aug 14, 2023
2 parents dd1731e + caaee3b commit 6e8242e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 28 deletions.
13 changes: 12 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{
"extends": ["@adobe/eslint-config-aio-lib-config"]
"extends": [
"@adobe/eslint-config-aio-lib-config"
],
"rules": {
"jsdoc/tag-lines": [
"error",
"never",
{
"startLines": null
}
]
}
}
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@
"description": "Adobe I/O Lib Core Networking",
"devDependencies": {
"@adobe/aio-lib-test-proxy": "^1.0.0",
"@adobe/eslint-config-aio-lib-config": "^2.0.0",
"@adobe/eslint-config-aio-lib-config": "^2.0.1",
"babel-runtime": "^6.26.0",
"dotenv": "^8.1.0",
"dotenv": "^16.3.1",
"eol": "^0.9.1",
"eslint": "^8.17.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-jsdoc": "^37.9.7",
"eslint-plugin-n": "^15.2.1",
"eslint": "^8.47.0",
"eslint-config-standard": "^17.1.0",
"eslint-plugin-import": "^2.28.0",
"eslint-plugin-jest": "^27.2.3",
"eslint-plugin-jsdoc": "^42.0.0",
"eslint-plugin-n": "^16.0.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-standard": "^5.0.0",
"fetch-mock": "^9.0.0",
"jest": "^29.5.0",
Expand All @@ -48,7 +48,7 @@
"query-string": "^7.0.1",
"stdout-stderr": "^0.1.9",
"tsd-jsdoc": "^2.4.0",
"typescript": "^4.7.3"
"typescript": "^4.9.5"
},
"scripts": {
"e2e": "jest --config e2e/jest.config.js",
Expand Down
34 changes: 17 additions & 17 deletions test/HttpExponentialBackoff.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ beforeEach(() => {
jest.useRealTimers()
})

test('test exponential backoff with success in first attempt without mock retryOn', async () => {
test('exponential backoff with success in first attempt without mock retryOn', async () => {
const result = await fetchClient.exponentialBackoff('https://abc.com/', { method: 'GET' })
expect(result.status).toBe(200)
})

test('test exponentialBackoff with no retries on 4xx errors without mock retryOn', async () => {
test('exponentialBackoff with no retries on 4xx errors without mock retryOn', async () => {
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn')
fetchMock.mockResponse('404 Not Found', {
status: 404
Expand All @@ -72,7 +72,7 @@ test('test exponentialBackoff with no retries on 4xx errors without mock retryOn
retrySpy.mockRestore()
})

test('test exponentialBackoff with 3 retries on 5xx errors without mock retryOn', async () => {
test('exponentialBackoff with 3 retries on 5xx errors without mock retryOn', async () => {
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn')
fetchMock.mockResponse('500 Internal Server Error', {
status: 500
Expand All @@ -83,7 +83,7 @@ test('test exponentialBackoff with 3 retries on 5xx errors without mock retryOn'
retrySpy.mockRestore()
})

test('test exponential backoff with success in first attempt', async () => {
test('exponential backoff with success in first attempt', async () => {
const mockDefaultFn = __testRetryOnHelper(3)
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn').mockImplementation((retries) => {
return mockDefaultFn
Expand All @@ -98,7 +98,7 @@ test('test exponential backoff with success in first attempt', async () => {
retrySpy.mockRestore()
})

test('test exponentialBackoff with no retries on 4xx errors and default retry strategy', async () => {
test('exponentialBackoff with no retries on 4xx errors and default retry strategy', async () => {
const mockDefaultFn = __testRetryOnHelper(3)
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn').mockImplementation((retries) => {
return mockDefaultFn
Expand All @@ -113,7 +113,7 @@ test('test exponentialBackoff with no retries on 4xx errors and default retry st
retrySpy.mockRestore()
})

test('test exponentialBackoff with 3 retries on 429 errors and default retry strategy', async () => {
test('exponentialBackoff with 3 retries on 429 errors and default retry strategy', async () => {
const mockDefaultFn = __testRetryOnHelper(3)
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn').mockImplementation((retries) => mockDefaultFn)
fetchMock.mockResponse('429 Too many requests', {
Expand All @@ -126,7 +126,7 @@ test('test exponentialBackoff with 3 retries on 429 errors and default retry str
retrySpy.mockRestore()
})

test('test exponentialBackoff with 3 retries on 5xx errors and default retry strategy', async () => {
test('exponentialBackoff with 3 retries on 5xx errors and default retry strategy', async () => {
const mockDefaultFn = __testRetryOnHelper(3)
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn').mockImplementation((retries) => {
return mockDefaultFn
Expand All @@ -141,7 +141,7 @@ test('test exponentialBackoff with 3 retries on 5xx errors and default retry str
retrySpy.mockRestore()
})

test('test exponentialBackoff with 3 retries on errors with default retry strategy and date in Retry-After header', async () => {
test('exponentialBackoff with 3 retries on errors with default retry strategy and date in Retry-After header', async () => {
const spy = jest.spyOn(global.Date, 'now').mockImplementation(() => new Date('Mon, 13 Feb 2023 23:59:59 GMT'))
const header = 'Tue, 14 Feb 2023 00:00:00 GMT'
fetchMock.mockResponse('503 Service Unavailable', {
Expand All @@ -155,7 +155,7 @@ test('test exponentialBackoff with 3 retries on errors with default retry strate
expect(spy).toHaveBeenCalledTimes(2)
})

test('test exponential backoff with success in first attempt and custom retryOptions', async () => {
test('exponential backoff with success in first attempt and custom retryOptions', async () => {
const mockDefaultFn = __testRetryOnHelper(2)
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn').mockImplementation((retries) => {
return mockDefaultFn
Expand All @@ -170,7 +170,7 @@ test('test exponential backoff with success in first attempt and custom retryOpt
retrySpy.mockRestore()
})

test('test exponentialBackoff with no retries on 4xx errors and custom retryOptions', async () => {
test('exponentialBackoff with no retries on 4xx errors and custom retryOptions', async () => {
const mockDefaultFn = __testRetryOnHelper(1)
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn').mockImplementation((retries) => {
return mockDefaultFn
Expand All @@ -185,7 +185,7 @@ test('test exponentialBackoff with no retries on 4xx errors and custom retryOpti
retrySpy.mockRestore()
})

test('test exponentialBackoff with 3 retries on 5xx errors and custom retryOptions', async () => {
test('exponentialBackoff with 3 retries on 5xx errors and custom retryOptions', async () => {
const mockDefaultFn = __testRetryOnHelper(2)
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn').mockImplementation((retries) => {
return mockDefaultFn
Expand All @@ -200,7 +200,7 @@ test('test exponentialBackoff with 3 retries on 5xx errors and custom retryOptio
retrySpy.mockRestore()
})

test('test exponential backoff with success in first attempt and custom retryOn', async () => {
test('exponential backoff with success in first attempt and custom retryOn', async () => {
const mockDefaultFn = __testRetryOnHelper(2, 399, 500)
fetchMock.mockResponse('200 OK', {
status: 200
Expand All @@ -210,7 +210,7 @@ test('test exponential backoff with success in first attempt and custom retryOn'
expect(mockDefaultFn).toHaveBeenCalledTimes(1)
})

test('test exponentialBackoff with no retries on 4xx errors and custom retryOn', async () => {
test('exponentialBackoff with no retries on 4xx errors and custom retryOn', async () => {
const mockDefaultFn = __testRetryOnHelper(2, 399, 500)
fetchMock.mockResponse('404 Not Found', {
status: 404
Expand All @@ -221,7 +221,7 @@ test('test exponentialBackoff with no retries on 4xx errors and custom retryOn',
expect(mockDefaultFn).toHaveBeenCalledTimes(3)
})

test('test exponentialBackoff with 3 retries on 5xx errors and custom retryOn', async () => {
test('exponentialBackoff with 3 retries on 5xx errors and custom retryOn', async () => {
const mockDefaultFn = __testRetryOnHelper(2, 399, 500)
const retrySpy = jest.spyOn(fetchClient, '__getRetryOn')
fetchMock.mockResponse('500 Internal Server Error', {
Expand All @@ -236,7 +236,7 @@ test('test exponentialBackoff with 3 retries on 5xx errors and custom retryOn',
retrySpy.mockRestore()
})

test('test exponentialBackoff with default 3 retries on 5xx errors and custom retryOn as array', async () => {
test('exponentialBackoff with default 3 retries on 5xx errors and custom retryOn as array', async () => {
const mockDefaultFn = [429, 500, 503]
fetchMock.mockResponse('429 Too Many Requests', {
status: 429
Expand All @@ -245,7 +245,7 @@ test('test exponentialBackoff with default 3 retries on 5xx errors and custom re
expect(result.status).toBe(429)
})

test('test exponentialBackoff with 3 retries on 5xx errors and custom retryDelay', async () => {
test('exponentialBackoff with 3 retries on 5xx errors and custom retryDelay', async () => {
const mockDefaultFn1 = __testRetryDelayHelper(100)
fetchMock.mockResponse('503 Service Unavailable', {
status: 503,
Expand All @@ -256,7 +256,7 @@ test('test exponentialBackoff with 3 retries on 5xx errors and custom retryDelay
expect(mockDefaultFn1).toHaveBeenCalledTimes(2)
})

test('test exponentialBackoff with no retries on 4xx errors and custom retryDelay', async () => {
test('exponentialBackoff with no retries on 4xx errors and custom retryDelay', async () => {
const mockDefaultFn = __testRetryDelayHelper(100)
fetchMock.mockResponse('404 Not Found', {
status: 404
Expand Down

0 comments on commit 6e8242e

Please sign in to comment.