Skip to content

Commit bf8ef3a

Browse files
Merge #727
727: Cleaning in tests r=bidoubiwa a=bidoubiwa Based on these comments the tests are made more readable and consistent: - new lines between concerns - No redundant `Test` in front of test name - Creation of default contexts where possible - remove duplicated tests - Group related <hr> - #707 (comment) - #707 (comment) - #707 (comment) - #707 (comment) - #707 (comment) - #707 (comment) Co-authored-by: Charlotte Vermandel <[email protected]> Co-authored-by: cvermand <[email protected]>
2 parents b50fb65 + fc4b170 commit bf8ef3a

16 files changed

+302
-265
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Usage:
126126

127127
### Finite Pagination
128128

129-
Finite pagination is used when you want to add a numbered pagination at the bottom of your hits (for example: `< << 1, 2, 3 > >>`).
129+
Finite pagination is used when you want to add a numbered pagination at the bottom of your hits (for example: `<< < 1, 2, 3 > >>`).
130130
To be able to know the amount of page numbers you have, a search is done requesting `paginationTotalHits` documents (default: `200`).
131131
With the amount of documents returned, instantsearch is able to render the correct amount of numbers in the pagination widget.
132132

src/adapter/search-request-adapter/__tests__/facets-distribution-assigns.tests.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ test('One field in cache present in distribution', () => {
55
{ genre: ['comedy'] },
66
{ genre: { comedy: 1 } }
77
)
8+
89
expect(returnedDistribution).toMatchObject({ genre: { comedy: 1 } })
910
})
1011

1112
test('One field in cache not present in distribution', () => {
1213
const returnedDistribution = addMissingFacets({ genre: ['comedy'] }, {})
14+
1315
expect(returnedDistribution).toMatchObject({ genre: { comedy: 0 } })
1416
})
1517

@@ -18,6 +20,7 @@ test('two field in cache only one present in distribution', () => {
1820
{ genre: ['comedy'], title: ['hamlet'] },
1921
{ genre: { comedy: 12 } }
2022
)
23+
2124
expect(returnedDistribution).toMatchObject({
2225
genre: { comedy: 12 },
2326
title: { hamlet: 0 },
@@ -29,6 +32,7 @@ test('two field in cache w/ different facet name none present in distribution',
2932
{ genre: ['comedy'], title: ['hamlet'] },
3033
{}
3134
)
35+
3236
expect(returnedDistribution).toMatchObject({
3337
genre: { comedy: 0 },
3438
title: { hamlet: 0 },
@@ -40,6 +44,7 @@ test('two field in cache w/ different facet name both present in distribution',
4044
{ genre: ['comedy'], title: ['hamlet'] },
4145
{ genre: { comedy: 12 }, title: { hamlet: 1 } }
4246
)
47+
4348
expect(returnedDistribution).toMatchObject({
4449
genre: { comedy: 12 },
4550
title: { hamlet: 1 },
@@ -51,6 +56,7 @@ test('Three field in cache w/ different facet name two present in distribution',
5156
{ genre: ['comedy', 'horror'], title: ['hamlet'] },
5257
{ genre: { comedy: 12 }, title: { hamlet: 1 } }
5358
)
59+
5460
expect(returnedDistribution).toMatchObject({
5561
genre: { comedy: 12, horror: 0 },
5662
title: { hamlet: 1 },
@@ -61,25 +67,30 @@ test('Cache is undefined and facets distribution is not', () => {
6167
const returnedDistribution = addMissingFacets(undefined, {
6268
genre: { comedy: 12 },
6369
})
70+
6471
expect(returnedDistribution).toMatchObject({ genre: { comedy: 12 } })
6572
})
6673

6774
test('Cache is empty object and facets distribution is not', () => {
6875
const returnedDistribution = addMissingFacets({}, { genre: { comedy: 12 } })
76+
6977
expect(returnedDistribution).toMatchObject({ genre: { comedy: 12 } })
7078
})
7179

7280
test('Cache is empty object and facets distribution empty object', () => {
7381
const returnedDistribution = addMissingFacets({}, {})
82+
7483
expect(returnedDistribution).toMatchObject({})
7584
})
7685

7786
test('Cache is undefined and facets distribution empty object', () => {
7887
const returnedDistribution = addMissingFacets(undefined, {})
88+
7989
expect(returnedDistribution).toMatchObject({})
8090
})
8191

8292
test('Cache is undefined and facets distribution is undefined', () => {
8393
const returnedDistribution = addMissingFacets(undefined, undefined)
94+
8495
expect(returnedDistribution).toMatchObject({})
8596
})

src/adapter/search-request-adapter/__tests__/filter-cache.tests.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe.each(facetCacheData)(
6464
{ keepZeroFacets: false, defaultFacetDistribution: {} },
6565
{ filter: filters }
6666
)
67+
6768
expect(cache).toEqual(expectedCache)
6869
})
6970
}

src/adapter/search-request-adapter/__tests__/geo-rules.tests.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,23 @@ test('Adapt geoPoints rules with integer geo points', () => {
1717
const rules = adaptGeoPointsRules({
1818
insideBoundingBox: '1,2,3,4',
1919
})
20+
2021
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)')
2122
})
2223

2324
test('Try geoContext with only a radius', () => {
2425
const rules = adaptGeoPointsRules({
2526
aroundRadius: 1,
2627
})
28+
2729
expect(rules).toBeUndefined()
2830
})
2931

3032
test('Try geoContext with an aroundLatLng', () => {
3133
const rules = adaptGeoPointsRules({
3234
aroundLatLng: '51.1241999, 9.662499900000057',
3335
})
36+
3437
expect(rules?.filter).toBeUndefined()
3538
})
3639

@@ -39,6 +42,7 @@ test('Try geoContext with an aroundLatLng and a radius', () => {
3942
aroundLatLng: '51.1241999, 9.662499900000057',
4043
aroundRadius: 1,
4144
})
45+
4246
expect(rules?.filter).toBe('_geoRadius(51.12420, 9.66250, 1)')
4347
})
4448

@@ -47,6 +51,7 @@ test('Try geoContext with an aroundLatLng and a 0 radius', () => {
4751
aroundLatLng: '51.1241999, 9.662499900000057',
4852
aroundRadius: 0,
4953
})
54+
5055
expect(rules?.filter).toBe('_geoRadius(51.12420, 9.66250, 0)')
5156
})
5257

@@ -56,19 +61,22 @@ test('Try geoContext with aroundLatLng, radius and insideBoundingBox', () => {
5661
aroundRadius: 1,
5762
insideBoundingBox: '1,2,3,4',
5863
})
64+
5965
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)')
6066
})
6167
test('Try geoContext with a radius and insideBoundingBox', () => {
6268
const rules = adaptGeoPointsRules({
6369
aroundRadius: 1,
6470
insideBoundingBox: '1,2,3,4',
6571
})
72+
6673
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)')
6774
})
6875
test('Try geoContext with aroundLatLng and insideBoundingBox', () => {
6976
const rules = adaptGeoPointsRules({
7077
aroundLatLng: '51.1241999, 9.662499900000057',
7178
insideBoundingBox: '1,2,3,4',
7279
})
80+
7381
expect(rules?.filter).toBe('_geoRadius(3.17650, 3.19394, 157201.47551181243)')
7482
})

0 commit comments

Comments
 (0)