Skip to content

Commit

Permalink
Fixed array checks in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
flevi29 committed May 22, 2024
1 parent 4078b58 commit 2cb6f8a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
26 changes: 13 additions & 13 deletions tests/get_search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ describe.each([
const response = await client.index(index.uid).searchGet('prince', {})

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('limit', 20)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand All @@ -111,7 +111,7 @@ describe.each([
.index(index.uid)
.searchGet('prince', { limit: 1 })
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 1)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand All @@ -125,7 +125,7 @@ describe.each([
.index(index.uid)
.search('', { sort: ['id:asc'] })
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
const hit = response.hits[0]
expect(hit.id).toEqual(1)
})
Expand All @@ -138,7 +138,7 @@ describe.each([
const hit = response.hits[0]

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('query', 'prince')
expect(Object.keys(hit).join(',')).toEqual(
Object.keys(dataset[1]).join(',')
Expand Down Expand Up @@ -171,7 +171,7 @@ describe.each([
.index(index.uid)
.searchGet('prince', { limit: 1 })
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 1)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand Down Expand Up @@ -209,7 +209,7 @@ describe.each([
showMatchesPosition: true,
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits[0]).toHaveProperty('_matchesPosition', {
comment: [{ start: 22, length: 6 }],
title: [{ start: 9, length: 6 }],
Expand All @@ -230,7 +230,7 @@ describe.each([
})

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 5)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand Down Expand Up @@ -305,7 +305,7 @@ describe.each([
showMatchesPosition: true,
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 5)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand Down Expand Up @@ -335,7 +335,7 @@ describe.each([
showMatchesPosition: true,
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 5)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand Down Expand Up @@ -370,7 +370,7 @@ describe.each([
genre: { romance: 2 },
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length).toEqual(2)
})

Expand All @@ -381,7 +381,7 @@ describe.each([
facets: ['genre'],
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length).toEqual(0)
})

Expand All @@ -391,7 +391,7 @@ describe.each([
filter: 'genre = "sci fi"',
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length).toEqual(1)
})

Expand All @@ -405,7 +405,7 @@ describe.each([
genre: { romance: 2 },
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length).toEqual(2)
})

Expand Down
42 changes: 21 additions & 21 deletions tests/search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe.each([
const response = await client.index(index.uid).search('prince', {})

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('limit', 20)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand All @@ -174,7 +174,7 @@ describe.each([
})

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 20)
expect(response.hits.length).toEqual(1)
Expand All @@ -187,7 +187,7 @@ describe.each([
.search('french book', { matchingStrategy: MatchingStrategies.LAST })

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 20)
expect(response.hits.length).toEqual(2)
Expand All @@ -200,7 +200,7 @@ describe.each([
.search('other', { q: 'prince' })

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('limit', 20)
expect(response).toHaveProperty('offset', 0)
expect(response.estimatedTotalHits).toBeDefined()
Expand All @@ -214,7 +214,7 @@ describe.each([
const response = await client.index(index.uid).search(null, { q: 'prince' })

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('limit', 20)
expect(response).toHaveProperty('offset', 0)
expect(response.estimatedTotalHits).toBeDefined()
Expand All @@ -229,7 +229,7 @@ describe.each([
.index(index.uid)
.search('"french book" about', {})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('limit', 20)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand All @@ -244,7 +244,7 @@ describe.each([
.index(index.uid)
.search('prince', { limit: 1 })
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 1)
expect(response.estimatedTotalHits).toEqual(2)
Expand All @@ -259,7 +259,7 @@ describe.each([
.index(index.uid)
.search('', { sort: ['id:asc'] })
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
const hit = response.hits[0]
expect(hit.id).toEqual(1)
})
Expand All @@ -274,7 +274,7 @@ describe.each([
const hit = response.hits[0]

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('query', 'prince')
expect(hit).toHaveProperty('_rankingScore')
})
Expand All @@ -289,7 +289,7 @@ describe.each([
const hit = response.hits[0]

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('query', 'prince')
expect(hit).toHaveProperty('_rankingScoreDetails')
expect(Object.keys(hit._rankingScoreDetails || {})).toEqual([
Expand All @@ -310,7 +310,7 @@ describe.each([
const hit = response.hits[0]

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('query', 'prince')
expect(Object.keys(hit).join(',')).toEqual(
Object.keys(dataset[1]).join(',')
Expand Down Expand Up @@ -346,7 +346,7 @@ describe.each([
const hit = response.hits[0]

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('query', 'prince')
expect(Object.keys(hit).join(',')).toEqual(
Object.keys(dataset[1]).join(',')
Expand All @@ -359,7 +359,7 @@ describe.each([
.index(index.uid)
.search('prince', { limit: 1 })
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 1)
expect(response.estimatedTotalHits).toEqual(2)
Expand Down Expand Up @@ -409,7 +409,7 @@ describe.each([
showMatchesPosition: true,
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits[0]).toHaveProperty('_matchesPosition', {
comment: [{ start: 22, length: 6 }],
title: [{ start: 9, length: 6 }],
Expand All @@ -429,7 +429,7 @@ describe.each([
showMatchesPosition: true,
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 5)
expect(response.estimatedTotalHits).toEqual(1)
Expand Down Expand Up @@ -505,7 +505,7 @@ describe.each([
showMatchesPosition: true,
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 5)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand Down Expand Up @@ -535,7 +535,7 @@ describe.each([
showMatchesPosition: true,
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response).toHaveProperty('offset', 0)
expect(response).toHaveProperty('limit', 5)
expect(response).toHaveProperty('processingTimeMs', expect.any(Number))
Expand Down Expand Up @@ -595,7 +595,7 @@ describe.each([
expect(response.facetStats).toEqual({ id: { min: 2, max: 123 } })
expect(response.facetStats?.['id']?.max).toBe(123)
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length).toEqual(2)
})

Expand All @@ -605,7 +605,7 @@ describe.each([
filter: 'id < 0',
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length).toEqual(0)
})

Expand All @@ -616,7 +616,7 @@ describe.each([
})

expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length).toEqual(1)
})

Expand All @@ -630,7 +630,7 @@ describe.each([
genre: { romance: 2 },
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length).toEqual(2)
})

Expand Down
2 changes: 1 addition & 1 deletion tests/typed_search.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ describe.each([
filter: ['genre="sci fi"'],
})
expect(response).toHaveProperty('hits')
expect(Array.isArray(response.hits))
expect(Array.isArray(response.hits)).toBe(true)
expect(response.hits.length === 1).toBeTruthy()
})

Expand Down

0 comments on commit 2cb6f8a

Please sign in to comment.