Skip to content

Commit 436ce35

Browse files
committed
Merge branch 'main' into fix/js-build
2 parents 2a9f1bb + f829d14 commit 436ce35

File tree

14 files changed

+190
-59
lines changed

14 files changed

+190
-59
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

templates/php/tests/requests/requests.mustache

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ class {{clientPrefix}}Test extends TestCase implements HttpClientInterface
117117
{{#request.body}}
118118
"body" => json_decode("{{#lambda.escapeQuotes}}{{{request.body}}}{{/lambda.escapeQuotes}}"),
119119
{{/request.body}}
120+
{{^request.body}}
121+
{{#assertNullBody}}
122+
"body" => null,
123+
{{/assertNullBody}}
124+
{{^assertNullBody}}
125+
"body" => json_decode(""),
126+
{{/assertNullBody}}
127+
{{/request.body}}
120128
{{#request.queryParameters}}
121129
"queryParameters" => json_decode("{{#lambda.escapeQuotes}}{{{request.queryParameters}}}{{/lambda.escapeQuotes}}", true),
122130
{{/request.queryParameters}}

tests/output/php/src/methods/requests/AbtestingTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public function testDel0()
138138
[
139139
'path' => '/1/test/minimal',
140140
'method' => 'DELETE',
141+
'body' => null,
141142
],
142143
]);
143144
}
@@ -158,6 +159,7 @@ public function testDel1()
158159
[
159160
'path' => '/1/test/all',
160161
'method' => 'DELETE',
162+
'body' => null,
161163
'queryParameters' => json_decode(
162164
"{\"query\":\"parameters\"}",
163165
true
@@ -179,6 +181,7 @@ public function testDeleteABTest0()
179181
[
180182
'path' => '/2/abtests/42',
181183
'method' => 'DELETE',
184+
'body' => null,
182185
],
183186
]);
184187
}
@@ -196,6 +199,7 @@ public function testGet0()
196199
[
197200
'path' => '/1/test/minimal',
198201
'method' => 'GET',
202+
'body' => null,
199203
],
200204
]);
201205
}
@@ -216,6 +220,7 @@ public function testGet1()
216220
[
217221
'path' => '/1/test/all',
218222
'method' => 'GET',
223+
'body' => null,
219224
'queryParameters' => json_decode(
220225
"{\"query\":\"parameters\"}",
221226
true
@@ -237,6 +242,7 @@ public function testGetABTest0()
237242
[
238243
'path' => '/2/abtests/42',
239244
'method' => 'GET',
245+
'body' => null,
240246
],
241247
]);
242248
}
@@ -257,6 +263,7 @@ public function testListABTests0()
257263
[
258264
'path' => '/2/abtests',
259265
'method' => 'GET',
266+
'body' => null,
260267
'queryParameters' => json_decode(
261268
"{\"offset\":\"42\",\"limit\":\"21\"}",
262269
true
@@ -671,6 +678,7 @@ public function testStopABTest0()
671678
[
672679
'path' => '/2/abtests/42/stop',
673680
'method' => 'POST',
681+
'body' => json_decode(''),
674682
],
675683
]);
676684
}

0 commit comments

Comments
 (0)