Skip to content

Commit

Permalink
fix(slider): hide the slider when stats.min=stats.max
Browse files Browse the repository at this point in the history
  • Loading branch information
maxiloc committed Nov 25, 2015
1 parent fc3e15f commit 42e4b64
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/widgets/range-slider/__tests__/range-slider-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,49 @@ describe('rangeSlider()', () => {
});
});

context('when rangestats min === stats max', () => {
beforeEach(() => {
results = {
disjunctiveFacets: [{
name: 'aNumAttr',
data: {
65: 1
},
exhaustive: true,
stats: {
min: 65,
max: 65,
avg: 65,
sum: 65
}
}]
};
});

it('should shouldAutoHideContainer', () => {
widget.render({results, helper});

let props = {
cssClasses: {body: null, root: null},
onChange: () => {},
pips: true,
range: {max: 65, min: 65},
shouldAutoHideContainer: true,
start: [-Infinity, Infinity],
step: 1,
templateProps: {
templates: {footer: '', header: ''},
templatesConfig: undefined,
transformData: undefined,
useCustomCompileOptions: {footer: false, header: false}
},
tooltips: true
};

expect(ReactDOM.render.firstCall.args[0]).toEqualJSX(<Slider {...props} />);
});
});

context('with results', () => {
beforeEach(() => {
results = {
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/range-slider/range-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function rangeSlider({
};
}

let hasNoRefinements = stats.min === null && stats.max === null;
let hasNoRefinements = stats.min === stats.max;

let templateProps = utils.prepareTemplateProps({
defaultTemplates,
Expand Down

0 comments on commit 42e4b64

Please sign in to comment.