Skip to content

Commit

Permalink
fix(range-slider): check usage + display (fixes #395)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Stanislawski committed Nov 10, 2015
1 parent cbd2e4c commit 301643a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
14 changes: 14 additions & 0 deletions widgets/range-slider/__tests__/range-slider-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ expect.extend(expectJSX);

import AlgoliasearchHelper from 'algoliasearch-helper';

describe('rangeSlider call', () => {
jsdom({useEach: true});
const rangeSlider = require('../range-slider');
it('throws an exception when no attributeName', () => {
const containerNode = document.createElement('div');
expect(rangeSlider.bind(null, {containerNode})).toThrow();
});

it('throws an exception when no container', () => {
const attributeName = 'myAttribute';
expect(rangeSlider.bind(null, {attributeName})).toThrow();
});
});

describe('rangeSlider()', () => {
jsdom({useEach: true});

Expand Down
15 changes: 14 additions & 1 deletion widgets/range-slider/range-slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,21 @@ function rangeSlider({
step = 1,
pips = true,
autoHideContainer = true
}) {
} = {}) {
let containerNode = utils.getContainerNode(container);
if (!containerNode || !attributeName) {
throw new Error(`Usage:
rangeSlider({
container,
attributeName,
[ tooltips=true ],
[ templates={ header: '', footer: ''} ],
[ cssClasses={ root: null, body: null } ],
[ step=1 ],
[ pips=true ],
[ autoHideContainer=true ]
});`);
}

let Slider = headerFooterHOC(require('../../components/Slider/Slider'));
if (autoHideContainer === true) {
Expand Down

0 comments on commit 301643a

Please sign in to comment.