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

Commita2957af

Browse files
committed
test
1 parenta96c951 commita2957af

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
// If no initial interval is provided, the default must be 5 seconds.
19+
expect(retryDelay(0,undefined)).toBe(5000);
20+
// If the error is a slow down error, the interval should increase by 5 seconds
21+
// for this and all subsequent requests, and by 5 seconds extra delay for this
22+
// request.
23+
expect(retryDelay(1,slowDownError)).toBe(15000);
24+
expect(retryDelay(1,slowDownError)).toBe(15000);
25+
expect(retryDelay(2,undefined)).toBe(10000);
26+
27+
// Like previous request.
28+
expect(retryDelay(3,slowDownError)).toBe(20000);
29+
expect(retryDelay(3,undefined)).toBe(15000);
30+
// If the error is not a slow down error, the interval should not increase.
31+
expect(retryDelay(4,newAxiosError("other","500"))).toBe(15000);
32+
33+
// If the initial interval is provided, it should be used.
34+
constretryDelayWithInitialInterval=newRetryDelay(1);
35+
expect(retryDelayWithInitialInterval(0,undefined)).toBe(1000);
36+
expect(retryDelayWithInitialInterval(1,slowDownError)).toBe(11000);
37+
expect(retryDelayWithInitialInterval(2,undefined)).toBe(6000);
38+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp