Skip to content

Commit f829d14

Browse files
authored
fix(javascript): utils tests run time (#908)
1 parent 7ea03e6 commit f829d14

File tree

4 files changed

+32
-32
lines changed

4 files changed

+32
-32
lines changed

clients/algoliasearch-client-javascript/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
});

clients/algoliasearch-client-javascript/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

clients/algoliasearch-client-javascript/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

clients/algoliasearch-client-javascript/packages/requester-node-http/src/__tests__/node-http-requester.test.ts

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

194194
expect(response.content).toBe('Connection timeout');
195-
expect(now - before).toBeGreaterThan(999);
196-
expect(now - before).toBeLessThan(1200);
195+
expect(now - before).toBeGreaterThanOrEqual(999);
196+
expect(now - before).toBeLessThanOrEqual(1200);
197197
});
198198

199199
it('connection timeouts with the given 2 seconds connection timeout', async () => {
@@ -207,8 +207,8 @@ describe('timeout handling', () => {
207207
const now = Date.now();
208208

209209
expect(response.content).toBe('Connection timeout');
210-
expect(now - before).toBeGreaterThan(1999);
211-
expect(now - before).toBeLessThan(2200);
210+
expect(now - before).toBeGreaterThanOrEqual(1999);
211+
expect(now - before).toBeLessThanOrEqual(2200);
212212
});
213213

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

225225
expect(response.content).toBe('Socket timeout');
226-
expect(now - before).toBeGreaterThan(1999);
227-
expect(now - before).toBeLessThan(2200);
226+
expect(now - before).toBeGreaterThanOrEqual(1999);
227+
expect(now - before).toBeLessThanOrEqual(2200);
228228
});
229229

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

240240
expect(response.content).toBe('Socket timeout');
241-
expect(now - before).toBeGreaterThan(2999);
242-
expect(now - before).toBeLessThan(3200);
241+
expect(now - before).toBeGreaterThanOrEqual(2999);
242+
expect(now - before).toBeLessThanOrEqual(3200);
243243
});
244244

245245
it('do not timeouts if response appears before the timeout', async () => {
@@ -255,8 +255,8 @@ describe('timeout handling', () => {
255255
expect(response.isTimedOut).toBe(false);
256256
expect(response.status).toBe(200);
257257
expect(response.content).toBe('{"foo": "bar"}');
258-
expect(now - before).toBeGreaterThan(4999);
259-
expect(now - before).toBeLessThan(5200);
258+
expect(now - before).toBeGreaterThanOrEqual(4999);
259+
expect(now - before).toBeLessThanOrEqual(5200);
260260
}, 10000); // This is a long-running test, default server timeout is set to 5000ms
261261
});
262262

0 commit comments

Comments
 (0)