Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit454488b

Browse files
committed
test
1 parenta96c951 commit454488b

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import{newRetryDelay}from"./GitDeviceAuth";
2+
import{AxiosError,typeAxiosResponse}from"axios";
3+
4+
test("device auth retry delay",async()=>{
5+
constslowDownError=newAxiosError(
6+
"slow_down",
7+
"500",
8+
undefined,
9+
undefined,
10+
{
11+
data:{
12+
detail:"slow_down",
13+
},
14+
}asAxiosResponse,
15+
);
16+
constretryDelay=newRetryDelay(undefined);
17+
18+
expect(retryDelay(0,undefined)).toBe(5000);
19+
// If the error is a slow down error, the interval should increase by 5 seconds
20+
// for this and all subsequent requests, and by 5 seconds extra delay for this
21+
// request.
22+
expect(retryDelay(1,slowDownError)).toBe(15000);
23+
expect(retryDelay(1,slowDownError)).toBe(15000);
24+
expect(retryDelay(2,undefined)).toBe(10000);
25+
26+
// Like previous request.
27+
expect(retryDelay(3,slowDownError)).toBe(20000);
28+
expect(retryDelay(3,undefined)).toBe(15000);
29+
// If the error is not a slow down error, the interval should not increase.
30+
expect(retryDelay(4,newAxiosError("other","500"))).toBe(15000);
31+
32+
// If the initial interval is provided, it should be used.
33+
constretryDelayWithInitialInterval=newRetryDelay(1);
34+
expect(retryDelayWithInitialInterval(0,undefined)).toBe(1000);
35+
expect(retryDelayWithInitialInterval(1,slowDownError)).toBe(11000);
36+
expect(retryDelayWithInitialInterval(2,undefined)).toBe(6000);
37+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp