Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
fix(results): revert commit that ensure hits are returned only if rig…
Browse files Browse the repository at this point in the history
…ht indices (#149)

This was breaking the SortBy feature.

We need to find another way to handle the switch between mono indices / multi indices.
  • Loading branch information
mthuret authored Jul 6, 2017
1 parent 3183b4a commit df9aa25
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ describe('connectHierarchicalMenu', () => {
getFacetValues: jest.fn(),
getFacetByName: () => true,
hits: [],
index: 'index',
};

results.getFacetValues.mockImplementationOnce(() => ({}));
Expand Down Expand Up @@ -335,7 +334,6 @@ describe('connectHierarchicalMenu', () => {
first: {
getFacetValues: jest.fn(),
getFacetByName: () => true,
index: 'first',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('connectHits', () => {
it('provides the current hits to the component', () => {
const hits = [{}];
const props = getProvidedProps(null, null, {
results: { hits, index: 'index' },
results: { hits },
});
expect(props).toEqual({ hits });
});
Expand All @@ -38,7 +38,7 @@ describe('connectHits', () => {
it('provides the current hits to the component', () => {
const hits = [{}];
const props = getProvidedProps(null, null, {
results: { second: { hits, index: 'second' } },
results: { second: { hits } },
});
expect(props).toEqual({ hits });
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('connectInfiniteHits', () => {
it('provides the current hits to the component', () => {
const hits = [{}];
const props = getProvidedProps(null, null, {
results: { hits, page: 0, hitsPerPage: 2, nbPages: 3, index: 'index' },
results: { hits, page: 0, hitsPerPage: 2, nbPages: 3 },
});
expect(props).toEqual({ hits, hasMore: true });
});
Expand All @@ -20,7 +20,7 @@ describe('connectInfiniteHits', () => {
const hits = [{}, {}];
const hits2 = [{}, {}];
const res1 = getProvidedProps(null, null, {
results: { hits, page: 0, hitsPerPage: 2, nbPages: 3, index: 'index' },
results: { hits, page: 0, hitsPerPage: 2, nbPages: 3 },
});
expect(res1.hits).toEqual(hits);
expect(res1.hasMore).toBe(true);
Expand All @@ -30,7 +30,6 @@ describe('connectInfiniteHits', () => {
page: 1,
hitsPerPage: 2,
nbPages: 3,
index: 'index',
},
});
expect(res2.hits).toEqual([...hits, ...hits2]);
Expand All @@ -42,7 +41,7 @@ describe('connectInfiniteHits', () => {
const hits2 = [{}, {}, {}, {}, {}, {}];
const hits3 = [{}, {}, {}, {}, {}, {}, {}, {}];
const res1 = getProvidedProps(null, null, {
results: { hits, page: 0, hitsPerPage: 6, nbPages: 10, index: 'index' },
results: { hits, page: 0, hitsPerPage: 6, nbPages: 10 },
});
expect(res1.hits).toEqual(hits);
expect(res1.hasMore).toBe(true);
Expand All @@ -52,7 +51,6 @@ describe('connectInfiniteHits', () => {
page: 1,
hitsPerPage: 6,
nbPages: 10,
index: 'index',
},
});
expect(res2.hits).toEqual([...hits, ...hits2]);
Expand All @@ -63,7 +61,6 @@ describe('connectInfiniteHits', () => {
page: 2,
hitsPerPage: 8,
nbPages: 10,
index: 'index',
},
});
expect(res3.hits).toEqual([...hits, ...hits2, ...hits3]);
Expand All @@ -74,7 +71,6 @@ describe('connectInfiniteHits', () => {
page: 2,
hitsPerPage: 8,
nbPages: 10,
index: 'index',
},
}); //re-render with the same property
expect(res3.hits).toEqual([...hits, ...hits2, ...hits3]);
Expand All @@ -94,7 +90,6 @@ describe('connectInfiniteHits', () => {
page,
hitsPerPage: hits.length,
nbPages,
index: 'index',
},
});
expect(res.hits).toEqual(allHits);
Expand All @@ -110,7 +105,6 @@ describe('connectInfiniteHits', () => {
page: nbPages - 1,
hitsPerPage: hits.length,
nbPages,
index: 'index',
},
});
expect(res.hits.length).toEqual(nbPages * 2);
Expand All @@ -123,15 +117,14 @@ describe('connectInfiniteHits', () => {
const hits2 = [{}, {}];
const hits3 = [{}];
getProvidedProps(null, null, {
results: { hits, page: 0, hitsPerPage: 2, nbPages: 3, index: 'index' },
results: { hits, page: 0, hitsPerPage: 2, nbPages: 3 },
});
getProvidedProps(null, null, {
results: {
hits: hits2,
page: 1,
hitsPerPage: 2,
nbPages: 3,
index: 'index',
},
});
const props = getProvidedProps(null, null, {
Expand All @@ -140,7 +133,6 @@ describe('connectInfiniteHits', () => {
page: 2,
hitsPerPage: 2,
nbPages: 3,
index: 'index',
},
});
expect(props.hits).toEqual([...hits, ...hits2, ...hits3]);
Expand Down Expand Up @@ -179,15 +171,7 @@ describe('connectInfiniteHits', () => {
it('provides the current hits to the component', () => {
const hits = [{}];
const props = getProvidedProps(null, null, {
results: {
second: {
hits,
page: 0,
hitsPerPage: 2,
nbPages: 3,
index: 'second',
},
},
results: { second: { hits, page: 0, hitsPerPage: 2, nbPages: 3 } },
});
expect(props).toEqual({ hits, hasMore: true });
});
Expand All @@ -196,27 +180,13 @@ describe('connectInfiniteHits', () => {
const hits = [{}, {}];
const hits2 = [{}, {}];
const res1 = getProvidedProps(null, null, {
results: {
second: {
hits,
page: 0,
hitsPerPage: 2,
nbPages: 3,
index: 'second',
},
},
results: { second: { hits, page: 0, hitsPerPage: 2, nbPages: 3 } },
});
expect(res1.hits).toEqual(hits);
expect(res1.hasMore).toBe(true);
const res2 = getProvidedProps(null, null, {
results: {
second: {
hits: hits2,
page: 1,
hitsPerPage: 2,
nbPages: 3,
index: 'second',
},
second: { hits: hits2, page: 1, hitsPerPage: 2, nbPages: 3 },
},
});
expect(res2.hits).toEqual([...hits, ...hits2]);
Expand All @@ -228,53 +198,27 @@ describe('connectInfiniteHits', () => {
const hits2 = [{}, {}, {}, {}, {}, {}];
const hits3 = [{}, {}, {}, {}, {}, {}, {}, {}];
const res1 = getProvidedProps(null, null, {
results: {
second: {
hits,
page: 0,
hitsPerPage: 6,
nbPages: 10,
index: 'second',
},
},
results: { second: { hits, page: 0, hitsPerPage: 6, nbPages: 10 } },
});
expect(res1.hits).toEqual(hits);
expect(res1.hasMore).toBe(true);
const res2 = getProvidedProps(null, null, {
results: {
second: {
hits: hits2,
page: 1,
hitsPerPage: 6,
nbPages: 10,
index: 'second',
},
second: { hits: hits2, page: 1, hitsPerPage: 6, nbPages: 10 },
},
});
expect(res2.hits).toEqual([...hits, ...hits2]);
expect(res2.hasMore).toBe(true);
let res3 = getProvidedProps(null, null, {
results: {
second: {
hits: hits3,
page: 2,
hitsPerPage: 8,
nbPages: 10,
index: 'second',
},
second: { hits: hits3, page: 2, hitsPerPage: 8, nbPages: 10 },
},
});
expect(res3.hits).toEqual([...hits, ...hits2, ...hits3]);
expect(res3.hasMore).toBe(true);
res3 = getProvidedProps(null, null, {
results: {
second: {
hits: hits3,
page: 2,
hitsPerPage: 8,
nbPages: 10,
index: 'second',
},
second: { hits: hits3, page: 2, hitsPerPage: 8, nbPages: 10 },
},
}); //re-render with the same property
expect(res3.hits).toEqual([...hits, ...hits2, ...hits3]);
Expand All @@ -295,7 +239,6 @@ describe('connectInfiniteHits', () => {
page,
hitsPerPage: hits.length,
nbPages,
index: 'second',
},
},
});
Expand All @@ -313,7 +256,6 @@ describe('connectInfiniteHits', () => {
page: nbPages - 1,
hitsPerPage: hits.length,
nbPages,
index: 'second',
},
},
});
Expand All @@ -327,36 +269,16 @@ describe('connectInfiniteHits', () => {
const hits2 = [{}, {}];
const hits3 = [{}];
getProvidedProps(null, null, {
results: {
second: {
hits,
page: 0,
hitsPerPage: 2,
nbPages: 3,
index: 'second',
},
},
results: { second: { hits, page: 0, hitsPerPage: 2, nbPages: 3 } },
});
getProvidedProps(null, null, {
results: {
second: {
hits: hits2,
page: 1,
hitsPerPage: 2,
nbPages: 3,
index: 'second',
},
second: { hits: hits2, page: 1, hitsPerPage: 2, nbPages: 3 },
},
});
const props = getProvidedProps(null, null, {
results: {
second: {
hits: hits3,
page: 2,
hitsPerPage: 2,
nbPages: 3,
index: 'second',
},
second: { hits: hits3, page: 2, hitsPerPage: 2, nbPages: 3 },
},
});
expect(props.hits).toEqual([...hits, ...hits2, ...hits3]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ describe('connectMenu', () => {
getFacetValues: jest.fn(() => []),
getFacetByName: () => true,
hits: [],
index: 'index',
};

props = getProvidedProps({ attributeName: 'ok' }, {}, {});
Expand Down Expand Up @@ -213,7 +212,6 @@ describe('connectMenu', () => {
getFacetValues: jest.fn(() => []),
getFacetByName: () => true,
hits: [],
index: 'index',
};
results.getFacetValues.mockImplementation(() => [
{
Expand Down Expand Up @@ -388,7 +386,6 @@ describe('connectMenu', () => {
getFacetValues: jest.fn(() => []),
getFacetByName: () => true,
hits: [],
index: 'index',
};
results.getFacetValues.mockClear();
results.getFacetValues.mockImplementation(() => [
Expand Down Expand Up @@ -465,7 +462,6 @@ describe('connectMenu', () => {
first: {
getFacetValues: jest.fn(() => []),
getFacetByName: () => true,
index: 'first',
},
};

Expand Down Expand Up @@ -654,7 +650,6 @@ describe('connectMenu', () => {
first: {
getFacetValues: jest.fn(() => []),
getFacetByName: () => true,
index: 'first',
},
};
results.first.getFacetValues.mockImplementation(() => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('connectMultiRange', () => {
getFacetStats: () => ({ min: 0, max: 300 }),
getFacetByName: () => true,
hits: [],
index: 'index',
};

it('provides the correct props to the component', () => {
Expand Down Expand Up @@ -373,7 +372,6 @@ describe('connectMultiRange', () => {
first: {
getFacetStats: () => ({ min: 0, max: 300 }),
getFacetByName: () => true,
index: 'first',
},
};

Expand Down
Loading

0 comments on commit df9aa25

Please sign in to comment.