@@ -195,64 +195,52 @@ describe.each([
195195
196196 describe ( 'Test on indexes methods' , ( ) => {
197197 test ( `${ permission } key: create with no primary key` , async ( ) => {
198- await client . createIndex ( indexNoPk . uid ) . then ( ( response ) => {
199- expect ( response ) . toHaveProperty ( 'uid' , indexNoPk . uid )
200- expect ( response ) . toHaveProperty ( 'primaryKey' , null )
201- } )
198+ const newIndex = await client . createIndex ( indexNoPk . uid )
199+ expect ( newIndex ) . toHaveProperty ( 'uid' , indexNoPk . uid )
200+ expect ( newIndex ) . toHaveProperty ( 'primaryKey' , null )
202201
203- await client
204- . index ( indexNoPk . uid )
205- . getRawInfo ( )
206- . then ( ( response : IndexResponse ) => {
207- expect ( response ) . toHaveProperty ( 'uid' , indexNoPk . uid )
208- expect ( response ) . toHaveProperty ( 'primaryKey' , null )
209- expect ( response ) . toHaveProperty ( 'createdAt' , expect . any ( String ) )
210- expect ( response ) . toHaveProperty ( 'updatedAt' , expect . any ( String ) )
211- } )
202+ const rawIndex = await client . index ( indexNoPk . uid ) . getRawInfo ( )
203+ expect ( rawIndex ) . toHaveProperty ( 'uid' , indexNoPk . uid )
204+ expect ( rawIndex ) . toHaveProperty ( 'primaryKey' , null )
205+ expect ( rawIndex ) . toHaveProperty ( 'createdAt' , expect . any ( String ) )
206+ expect ( rawIndex ) . toHaveProperty ( 'updatedAt' , expect . any ( String ) )
212207
213- await client . getIndex ( indexNoPk . uid ) . then ( ( response ) => {
214- expect ( response . primaryKey ) . toBe ( null )
215- expect ( response . uid ) . toBe ( indexNoPk . uid )
216- } )
208+ const response = await client . getIndex ( indexNoPk . uid )
209+ expect ( response . primaryKey ) . toBe ( null )
210+ expect ( response . uid ) . toBe ( indexNoPk . uid )
217211 } )
218212
219213 test ( `${ permission } key: create with primary key` , async ( ) => {
220- await client
221- . createIndex ( indexPk . uid , {
222- primaryKey : indexPk . primaryKey ,
223- } )
224- . then ( ( response ) => {
225- expect ( response ) . toHaveProperty ( 'uid' , indexPk . uid )
226- expect ( response ) . toHaveProperty ( 'primaryKey' , indexPk . primaryKey )
227- } )
228- await client
229- . index ( indexPk . uid )
230- . getRawInfo ( )
231- . then ( ( response : IndexResponse ) => {
232- expect ( response ) . toHaveProperty ( 'primaryKey' , indexPk . primaryKey )
233- expect ( response ) . toHaveProperty ( 'createdAt' , expect . any ( String ) )
234- expect ( response ) . toHaveProperty ( 'updatedAt' , expect . any ( String ) )
235- } )
236- await client . getIndex ( indexPk . uid ) . then ( ( response ) => {
237- expect ( response . primaryKey ) . toBe ( indexPk . primaryKey )
238- expect ( response . uid ) . toBe ( indexPk . uid )
214+ const newIndex = await client . createIndex ( indexPk . uid , {
215+ primaryKey : indexPk . primaryKey ,
239216 } )
217+ expect ( newIndex ) . toHaveProperty ( 'uid' , indexPk . uid )
218+ expect ( newIndex ) . toHaveProperty ( 'primaryKey' , indexPk . primaryKey )
219+
220+ const rawIndex = await client . index ( indexPk . uid ) . getRawInfo ( )
221+ expect ( rawIndex ) . toHaveProperty ( 'primaryKey' , indexPk . primaryKey )
222+ expect ( rawIndex ) . toHaveProperty ( 'createdAt' , expect . any ( String ) )
223+ expect ( rawIndex ) . toHaveProperty ( 'updatedAt' , expect . any ( String ) )
224+
225+ const response = await client . getIndex ( indexPk . uid )
226+ expect ( response . primaryKey ) . toBe ( indexPk . primaryKey )
227+ expect ( response . uid ) . toBe ( indexPk . uid )
240228 } )
241229
242230 test ( `${ permission } key: get all indexes when not empty` , async ( ) => {
243231 await client . createIndex ( indexPk . uid )
244- await client . getIndexes ( ) . then ( ( response : IndexResponse [ ] ) => {
245- const indexes = response . map ( ( index ) => index . uid )
246- expect ( indexes ) . toEqual ( expect . arrayContaining ( [ indexPk . uid ] ) )
247- expect ( indexes . length ) . toEqual ( 1 )
248- } )
232+
233+ const response : IndexResponse [ ] = await client . getIndexes ( )
234+ const indexes = response . map ( ( index ) => index . uid )
235+ expect ( indexes ) . toEqual ( expect . arrayContaining ( [ indexPk . uid ] ) )
236+ expect ( indexes . length ) . toEqual ( 1 )
249237 } )
250238
251239 test ( `${ permission } key: Get index that exists` , async ( ) => {
252240 await client . createIndex ( indexPk . uid )
253- await client . getIndex ( indexPk . uid ) . then ( ( response ) => {
254- expect ( response ) . toHaveProperty ( 'uid' , indexPk . uid )
255- } )
241+
242+ const response = await client . getIndex ( indexPk . uid )
243+ expect ( response ) . toHaveProperty ( 'uid' , indexPk . uid )
256244 } )
257245
258246 test ( `${ permission } key: Get index that does not exist` , async ( ) => {
@@ -264,12 +252,12 @@ describe.each([
264252
265253 test ( `${ permission } key: update primary key` , async ( ) => {
266254 await client . createIndex ( indexPk . uid )
267- await client
268- . updateIndex ( indexPk . uid , { primaryKey : 'newPrimaryKey' } )
269- . then ( ( response : Index < any > ) => {
270- expect ( response ) . toHaveProperty ( 'uid' , indexPk . uid )
271- expect ( response ) . toHaveProperty ( 'primaryKey ' , 'newPrimaryKey' )
272- } )
255+
256+ const response : Index < any > = await client . updateIndex ( indexPk . uid , {
257+ primaryKey : 'newPrimaryKey' ,
258+ } )
259+ expect ( response ) . toHaveProperty ( 'uid ' , indexPk . uid )
260+ expect ( response ) . toHaveProperty ( 'primaryKey' , 'newPrimaryKey' )
273261 } )
274262
275263 test ( `${ permission } key: update primary key that already exists` , async ( ) => {
@@ -288,9 +276,10 @@ describe.each([
288276
289277 test ( `${ permission } key: delete index` , async ( ) => {
290278 await client . createIndex ( indexNoPk . uid )
291- await client . deleteIndex ( indexNoPk . uid ) . then ( ( response : void ) => {
292- expect ( response ) . toBe ( undefined )
293- } )
279+
280+ const response : void = await client . deleteIndex ( indexNoPk . uid )
281+ expect ( response ) . toBe ( undefined )
282+
294283 await expect ( client . getIndexes ( ) ) . resolves . toHaveLength ( 0 )
295284 } )
296285
@@ -311,11 +300,10 @@ describe.each([
311300 } )
312301 test ( `${ permission } key: delete index if exists on existing index` , async ( ) => {
313302 await client . createIndex ( indexPk . uid )
314- await client
315- . deleteIndexIfExists ( indexPk . uid )
316- . then ( ( response : boolean ) => {
317- expect ( response ) . toBe ( true )
318- } )
303+
304+ const response : boolean = await client . deleteIndexIfExists ( indexPk . uid )
305+ expect ( response ) . toBe ( true )
306+
319307 await expect ( client . getIndex ( indexPk . uid ) ) . rejects . toHaveProperty (
320308 'errorCode' ,
321309 ErrorStatusCode . INDEX_NOT_FOUND
@@ -324,11 +312,9 @@ describe.each([
324312
325313 test ( `${ permission } key: delete index if exists on index that does not exist` , async ( ) => {
326314 const indexes = await client . getIndexes ( )
327- await client
328- . deleteIndexIfExists ( 'badIndex' )
329- . then ( ( response : boolean ) => {
330- expect ( response ) . toBe ( false )
331- } )
315+ const response : boolean = await client . deleteIndexIfExists ( 'badIndex' )
316+ expect ( response ) . toBe ( false )
317+
332318 await expect ( client . getIndex ( 'badIndex' ) ) . rejects . toHaveProperty (
333319 'errorCode' ,
334320 ErrorStatusCode . INDEX_NOT_FOUND
@@ -347,41 +333,36 @@ describe.each([
347333
348334 describe ( 'Test on base routes' , ( ) => {
349335 test ( `${ permission } key: get health` , async ( ) => {
350- await client . health ( ) . then ( ( response : Health ) => {
351- expect ( response ) . toHaveProperty (
352- 'status' ,
353- expect . stringMatching ( 'available' )
354- )
355- } )
336+ const response : Health = await client . health ( )
337+ expect ( response ) . toHaveProperty (
338+ 'status' ,
339+ expect . stringMatching ( 'available' )
340+ )
356341 } )
357342
358343 test ( `${ permission } key: is server healthy` , async ( ) => {
359- await client . isHealthy ( ) . then ( ( response : boolean ) => {
360- expect ( response ) . toBe ( true )
361- } )
344+ const response : boolean = await client . isHealthy ( )
345+ expect ( response ) . toBe ( true )
362346 } )
363347
364348 test ( `${ permission } key: is healthy return false on bad host` , async ( ) => {
365349 const client = new MeiliSearch ( { host : 'http://localhost:9345' } )
366- await client . isHealthy ( ) . then ( ( response : boolean ) => {
367- expect ( response ) . toBe ( false )
368- } )
350+ const response : boolean = await client . isHealthy ( )
351+ expect ( response ) . toBe ( false )
369352 } )
370353
371354 test ( `${ permission } key: get version` , async ( ) => {
372- await client . getVersion ( ) . then ( ( response : Version ) => {
373- expect ( response ) . toHaveProperty ( 'commitSha' , expect . any ( String ) )
374- expect ( response ) . toHaveProperty ( 'commitDate' , expect . any ( String ) )
375- expect ( response ) . toHaveProperty ( 'pkgVersion' , expect . any ( String ) )
376- } )
355+ const response : Version = await client . getVersion ( )
356+ expect ( response ) . toHaveProperty ( 'commitSha' , expect . any ( String ) )
357+ expect ( response ) . toHaveProperty ( 'commitDate' , expect . any ( String ) )
358+ expect ( response ) . toHaveProperty ( 'pkgVersion' , expect . any ( String ) )
377359 } )
378360
379361 test ( `${ permission } key: get /stats information` , async ( ) => {
380- await client . getStats ( ) . then ( ( response : Stats ) => {
381- expect ( response ) . toHaveProperty ( 'databaseSize' , expect . any ( Number ) )
382- expect ( response ) . toHaveProperty ( 'lastUpdate' ) // TODO: Could be null, find out why
383- expect ( response ) . toHaveProperty ( 'indexes' , expect . any ( Object ) )
384- } )
362+ const response : Stats = await client . getStats ( )
363+ expect ( response ) . toHaveProperty ( 'databaseSize' , expect . any ( Number ) )
364+ expect ( response ) . toHaveProperty ( 'lastUpdate' ) // TODO: Could be null, find out why
365+ expect ( response ) . toHaveProperty ( 'indexes' , expect . any ( Object ) )
385366 } )
386367 } )
387368 }
@@ -435,12 +416,11 @@ describe.each([{ client: publicClient, permission: 'Public' }])(
435416
436417 describe ( 'Test on misc client methods' , ( ) => {
437418 test ( `${ permission } key: get health` , async ( ) => {
438- await client . health ( ) . then ( ( response : Health ) => {
439- expect ( response ) . toHaveProperty (
440- 'status' ,
441- expect . stringMatching ( 'available' )
442- )
443- } )
419+ const response : Health = await client . health ( )
420+ expect ( response ) . toHaveProperty (
421+ 'status' ,
422+ expect . stringMatching ( 'available' )
423+ )
444424 } )
445425
446426 test ( `${ permission } key: try to get version and be denied` , async ( ) => {
@@ -528,12 +508,11 @@ describe.each([{ client: anonymousClient, permission: 'No' }])(
528508
529509 describe ( 'Test on misc client methods' , ( ) => {
530510 test ( `${ permission } key: get health` , async ( ) => {
531- await client . health ( ) . then ( ( response : Health ) => {
532- expect ( response ) . toHaveProperty (
533- 'status' ,
534- expect . stringMatching ( 'available' )
535- )
536- } )
511+ const response : Health = await client . health ( )
512+ expect ( response ) . toHaveProperty (
513+ 'status' ,
514+ expect . stringMatching ( 'available' )
515+ )
537516 } )
538517
539518 test ( `${ permission } key: try to get version and be denied` , async ( ) => {
0 commit comments