-
Notifications
You must be signed in to change notification settings - Fork 496
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #869 from algolia/fix/priceRanges-form
fix(priceRanges): pass the bound refine to the form
- Loading branch information
Showing
9 changed files
with
1,623 additions
and
1,104 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import expect from 'expect'; | ||
import {getCurrentRefinements} from '../utils.js'; | ||
|
||
describe('priceRanges', () => { | ||
const widget = '#price-ranges'; | ||
const item = '.item'; | ||
const priceRange = 'a*=$80'; | ||
|
||
it('has some default ranges', () => | ||
browser | ||
.element(widget) | ||
.elements(item) | ||
.then(items => | ||
expect(items.value.length) | ||
.toBe(7) | ||
) | ||
); | ||
|
||
it('can refine by clicking a range', () => | ||
browser | ||
.element(widget) | ||
.click(priceRange) | ||
.then(getCurrentRefinements) | ||
.then(refinements => | ||
expect(refinements.length).toBe(2) && | ||
expect(refinements[0].name).toBe('Price ≤ 160') && | ||
expect(refinements[1].name).toBe('Price ≥ 80') | ||
) | ||
); | ||
|
||
context('the form', () => { | ||
beforeEach(() => | ||
browser | ||
.element(widget) | ||
.setValue('label:nth-of-type(1) input', '94') | ||
.setValue('label:nth-of-type(2) input', '113') | ||
); | ||
|
||
it('can be submitted with ENTER key', () => | ||
browser | ||
.element(widget) | ||
.addValue('label:nth-of-type(2) input', 'Enter') | ||
.then(getCurrentRefinements) | ||
.then(refinements => expect(refinements.length).toBe(2) && | ||
expect(refinements[0].name).toBe('Price ≤ 113') && | ||
expect(refinements[1].name).toBe('Price ≥ 94') | ||
) | ||
); | ||
|
||
it('can be submitted by using the submit button', () => | ||
browser | ||
.element(widget) | ||
.click('button') | ||
.then(getCurrentRefinements) | ||
.then(refinements => expect(refinements.length).toBe(2) && | ||
expect(refinements[0].name).toBe('Price ≤ 113') && | ||
expect(refinements[1].name).toBe('Price ≥ 94') | ||
) | ||
); | ||
}); | ||
}); |
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
Oops, something went wrong.