Skip to content

Commit

Permalink
test(facetOrdering): use values for sortBy that aren't default
Browse files Browse the repository at this point in the history
  • Loading branch information
Haroenv committed Jul 5, 2021
1 parent 9e9d839 commit b417fa5
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/hierarchica
value: 'Decoration',
},
];
const resultsViaSortBy = [
const resultsViaDefaultSortBy = [
{
count: 880,
data: [
Expand Down Expand Up @@ -763,13 +763,48 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/hierarchica
value: 'Outdoor',
},
];
const resultsViaSortBy = [
{
count: 47,
data: null,
exhaustive: true,
isRefined: false,
label: 'Outdoor',
value: 'Outdoor',
},
{
count: 880,
data: [
{
count: 173,
data: null,
exhaustive: true,
isRefined: false,
label: 'Frames & pictures',
value: 'Decoration > Frames & pictures',
},
{
count: 193,
data: null,
exhaustive: true,
isRefined: false,
label: 'Candle holders & candles',
value: 'Decoration > Candle holders & candles',
},
],
exhaustive: true,
isRefined: true,
label: 'Decoration',
value: 'Decoration',
},
];

test.each`
facetOrderingInResult | sortBy | expected
${true} | ${undefined} | ${resultsViaFacetOrdering}
${false} | ${undefined} | ${resultsViaSortBy}
${true} | ${['name:asc']} | ${resultsViaSortBy}
${false} | ${['name:asc']} | ${resultsViaSortBy}
facetOrderingInResult | sortBy | expected
${true} | ${undefined} | ${resultsViaFacetOrdering}
${false} | ${undefined} | ${resultsViaDefaultSortBy}
${true} | ${['name:desc']} | ${resultsViaSortBy}
${false} | ${['name:desc']} | ${resultsViaSortBy}
`(
'renderingContent present: $facetOrderingInResult, sortBy: $sortBy',
({ facetOrderingInResult, sortBy, expected }) => {
Expand Down
38 changes: 32 additions & 6 deletions src/connectors/menu/__tests__/connectMenu-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/menu/js/#co
value: 'Algolia',
},
];
const resultsViaSortBy = [
const resultsViaDefaultSortBy = [
{
count: 3,
data: null,
Expand All @@ -702,13 +702,39 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/menu/js/#co
value: 'Samsung',
},
];
const resultsViaSortBy = [
{
count: 1,
data: null,
exhaustive: true,
isRefined: false,
label: 'Samsung',
value: 'Samsung',
},
{
count: 100,
data: null,
exhaustive: true,
isRefined: false,
label: 'Apple',
value: 'Apple',
},
{
count: 3,
data: null,
exhaustive: true,
isRefined: false,
label: 'Algolia',
value: 'Algolia',
},
];

test.each`
facetOrderingInResult | sortBy | expected
${true} | ${undefined} | ${resultsViaFacetOrdering}
${false} | ${undefined} | ${resultsViaSortBy}
${true} | ${['name:asc']} | ${resultsViaSortBy}
${false} | ${['name:asc']} | ${resultsViaSortBy}
facetOrderingInResult | sortBy | expected
${true} | ${undefined} | ${resultsViaFacetOrdering}
${false} | ${undefined} | ${resultsViaDefaultSortBy}
${true} | ${['name:desc']} | ${resultsViaSortBy}
${false} | ${['name:desc']} | ${resultsViaSortBy}
`(
'renderingContent present: $facetOrderingInResult, sortBy: $sortBy',
({ facetOrderingInResult, sortBy, expected }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2614,7 +2614,7 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/refinement-
value: 'Samsung',
},
];
const resultsViaSortBy = [
const resultsViaDefaultSortBy = [
{
count: 88,
highlighted: 'Apple',
Expand All @@ -2637,13 +2637,36 @@ See documentation: https://www.algolia.com/doc/api-reference/widgets/refinement-
value: 'Microsoft',
},
];
const resultsViaSortBy = [
{
count: 44,
highlighted: 'Samsung',
isRefined: true,
label: 'Samsung',
value: 'Samsung',
},
{
count: 66,
highlighted: 'Microsoft',
isRefined: false,
label: 'Microsoft',
value: 'Microsoft',
},
{
count: 88,
highlighted: 'Apple',
isRefined: true,
label: 'Apple',
value: 'Apple',
},
];

test.each`
facetOrderingInResult | sortBy | expected
${true} | ${undefined} | ${resultsViaFacetOrdering}
${false} | ${undefined} | ${resultsViaSortBy}
${true} | ${['isRefined']} | ${resultsViaSortBy}
${false} | ${['isRefined']} | ${resultsViaSortBy}
${false} | ${undefined} | ${resultsViaDefaultSortBy}
${true} | ${['name:desc']} | ${resultsViaSortBy}
${false} | ${['name:desc']} | ${resultsViaSortBy}
`(
'renderingContent present: $facetOrderingInResult, sortBy: $sortBy',
({ facetOrderingInResult, sortBy, expected }) => {
Expand Down

0 comments on commit b417fa5

Please sign in to comment.