Skip to content

Commit d5f5abf

Browse files
fix(javascript): utils tests run time
algolia/api-clients-automation#908 Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 08e031e commit d5f5abf

File tree

14 files changed

+262
-32
lines changed

14 files changed

+262
-32
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

packages/client-common/src/__tests__/create-iterable-promise.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('createIterablePromise', () => {
112112
await expect(promise).resolves.toEqual('success #2');
113113

114114
expect(Date.now() - before).toBeGreaterThanOrEqual(0);
115-
expect(Date.now() - before).toBeLessThan(10);
115+
expect(Date.now() - before).toBeLessThanOrEqual(10);
116116
expect(calls).toBe(2);
117117
});
118118

@@ -133,7 +133,7 @@ describe('createIterablePromise', () => {
133133
await expect(promise).resolves.toEqual('success #2');
134134

135135
expect(Date.now() - before).toBeGreaterThanOrEqual(2000);
136-
expect(Date.now() - before).toBeLessThan(2010);
136+
expect(Date.now() - before).toBeLessThanOrEqual(2010);
137137
expect(calls).toBe(2);
138138
});
139139
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md

packages/requester-browser-xhr/src/__tests__/browser-xhr-requester.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ describe('timeout handling', () => {
122122
const now = Date.now();
123123

124124
expect(response.content).toBe('Connection timeout');
125-
expect(now - before).toBeGreaterThan(999);
126-
expect(now - before).toBeLessThan(1200);
125+
expect(now - before).toBeGreaterThanOrEqual(999);
126+
expect(now - before).toBeLessThanOrEqual(1200);
127127
});
128128

129129
it('connection timeouts with the given 2 seconds connection timeout', async () => {
@@ -137,8 +137,8 @@ describe('timeout handling', () => {
137137
const now = Date.now();
138138

139139
expect(response.content).toBe('Connection timeout');
140-
expect(now - before).toBeGreaterThan(1990);
141-
expect(now - before).toBeLessThan(2200);
140+
expect(now - before).toBeGreaterThanOrEqual(1990);
141+
expect(now - before).toBeLessThanOrEqual(2200);
142142
});
143143

144144
it("socket timeouts if response don't appears before the timeout with 2 seconds timeout", async () => {
@@ -153,8 +153,8 @@ describe('timeout handling', () => {
153153
const now = Date.now();
154154

155155
expect(response.content).toBe('Socket timeout');
156-
expect(now - before).toBeGreaterThan(1990);
157-
expect(now - before).toBeLessThan(2200);
156+
expect(now - before).toBeGreaterThanOrEqual(1990);
157+
expect(now - before).toBeLessThanOrEqual(2200);
158158
});
159159

160160
it("socket timeouts if response don't appears before the timeout with 3 seconds timeout", async () => {
@@ -169,8 +169,8 @@ describe('timeout handling', () => {
169169
const now = Date.now();
170170

171171
expect(response.content).toBe('Socket timeout');
172-
expect(now - before).toBeGreaterThan(2999);
173-
expect(now - before).toBeLessThan(3200);
172+
expect(now - before).toBeGreaterThanOrEqual(2999);
173+
expect(now - before).toBeLessThanOrEqual(3200);
174174
});
175175

176176
it('do not timeouts if response appears before the timeout', async () => {
@@ -186,8 +186,8 @@ describe('timeout handling', () => {
186186
expect(response.isTimedOut).toBe(false);
187187
expect(response.status).toBe(200);
188188
expect(response.content).toBe('{"foo": "bar"}');
189-
expect(now - before).toBeGreaterThan(4999);
190-
expect(now - before).toBeLessThan(5200);
189+
expect(now - before).toBeGreaterThanOrEqual(4999);
190+
expect(now - before).toBeLessThanOrEqual(5200);
191191
}, 10000); // This is a long-running test, default server timeout is set to 5000ms
192192
});
193193

packages/requester-fetch/src/__tests__/fetch-requester.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ describe('timeout handling', () => {
136136
const now = Date.now();
137137

138138
expect(response.content).toBe('Connection timeout');
139-
expect(now - before).toBeGreaterThan(999);
140-
expect(now - before).toBeLessThan(1200);
139+
expect(now - before).toBeGreaterThanOrEqual(999);
140+
expect(now - before).toBeLessThanOrEqual(1200);
141141
});
142142

143143
it('connection timeouts with the given 2 seconds connection timeout', async () => {
@@ -151,8 +151,8 @@ describe('timeout handling', () => {
151151
const now = Date.now();
152152

153153
expect(response.content).toBe('Connection timeout');
154-
expect(now - before).toBeGreaterThan(1999);
155-
expect(now - before).toBeLessThan(2200);
154+
expect(now - before).toBeGreaterThanOrEqual(1999);
155+
expect(now - before).toBeLessThanOrEqual(2200);
156156
});
157157

158158
it("socket timeouts if response don't appears before the timeout with 2 seconds timeout", async () => {
@@ -167,8 +167,8 @@ describe('timeout handling', () => {
167167
const now = Date.now();
168168

169169
expect(response.content).toBe('Socket timeout');
170-
expect(now - before).toBeGreaterThan(1999);
171-
expect(now - before).toBeLessThan(2200);
170+
expect(now - before).toBeGreaterThanOrEqual(1999);
171+
expect(now - before).toBeLessThanOrEqual(2200);
172172
});
173173

174174
it("socket timeouts if response don't appears before the timeout with 3 seconds timeout", async () => {
@@ -182,8 +182,8 @@ describe('timeout handling', () => {
182182
const now = Date.now();
183183

184184
expect(response.content).toBe('Socket timeout');
185-
expect(now - before).toBeGreaterThan(2999);
186-
expect(now - before).toBeLessThan(3200);
185+
expect(now - before).toBeGreaterThanOrEqual(2999);
186+
expect(now - before).toBeLessThanOrEqual(3200);
187187
});
188188

189189
it('do not timeouts if response appears before the timeout', async () => {
@@ -199,8 +199,8 @@ describe('timeout handling', () => {
199199
expect(response.isTimedOut).toBe(false);
200200
expect(response.status).toBe(200);
201201
expect(response.content).toBe('{"foo": "bar"}');
202-
expect(now - before).toBeGreaterThan(4999);
203-
expect(now - before).toBeLessThan(5200);
202+
expect(now - before).toBeGreaterThanOrEqual(4999);
203+
expect(now - before).toBeLessThanOrEqual(5200);
204204
}, 10000); // This is a long-running test, default server timeout is set to 5000ms
205205
});
206206

0 commit comments

Comments
 (0)