forked from algolia/instantsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(getRefinements): provide attributeName for type: query
Closes algolia#3205 * fix(dev-novel): add example to dev-novel with onlyListedAttributes * fix(getRefinements) test connectCurrentRefinedValues with query refinements and onlyListedAttributes: true * fix(current-refined-values): wrap query refinement with <q> * fix(current-refined-values): add tests for defaultTemplates * fix(getRefinements): simplify tests for query
- Loading branch information
1 parent
56d71fd
commit 6a58b99
Showing
7 changed files
with
167 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
src/widgets/current-refined-values/__tests__/__snapshots__/defaultTemplates-test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`current-refined-values defaultTemplates \`item\` template does not show \`count\` when query refinement 1`] = `"Query : <q>Samsu</q> "`; | ||
|
||
exports[`current-refined-values defaultTemplates \`item\` template has a \`item\` default template 1`] = `"Brand : Samsung <span class=\\"ais-current-refined-values--count\\">4</span>"`; | ||
exports[`current-refined-values defaultTemplates \`item\` template wraps query refinements with <q> 1`] = `"Query : <q>Samsu</q> "`; |
43 changes: 43 additions & 0 deletions
43
src/widgets/current-refined-values/__tests__/defaultTemplates-test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import defaultTemplates from '../defaultTemplates.js'; | ||
|
||
describe('current-refined-values defaultTemplates', () => { | ||
describe('`item` template', () => { | ||
it('has a `item` default template', () => { | ||
const item = { | ||
type: 'disjunction', | ||
label: 'Brand', | ||
operator: ':', | ||
name: 'Samsung', | ||
count: 4, | ||
cssClasses: { | ||
count: 'ais-current-refined-values--count', | ||
}, | ||
}; | ||
expect(defaultTemplates.item(item)).toContain( | ||
'<span class="ais-current-refined-values--count">4</span>' | ||
); | ||
expect(defaultTemplates.item(item)).toMatchSnapshot(); | ||
}); | ||
it('wraps query refinements with <q>', () => { | ||
const item = { | ||
type: 'query', | ||
label: 'Query', | ||
operator: ':', | ||
name: 'Samsu', | ||
}; | ||
expect(defaultTemplates.item(item)).toContain('Query : <q>Samsu</q>'); | ||
expect(defaultTemplates.item(item)).toMatchSnapshot(); | ||
}); | ||
it('does not show `count` when query refinement', () => { | ||
const item = { | ||
type: 'query', | ||
label: 'Query', | ||
operator: ':', | ||
name: 'Samsu', | ||
count: 22, | ||
}; | ||
expect(defaultTemplates.item(item)).not.toContain(22); | ||
expect(defaultTemplates.item(item)).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters