Skip to content

Commit

Permalink
fix(price-ranges): fix usage + add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre Stanislawski committed Nov 10, 2015
1 parent f40cf42 commit 89601d7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
13 changes: 13 additions & 0 deletions widgets/price-ranges/__tests__/price-ranges-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ import priceRanges from '../price-ranges';
import generateRanges from '../generate-ranges';
import PriceRanges from '../../../components/PriceRanges/PriceRanges';

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

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

describe('priceRanges()', () => {
let ReactDOM;
let container;
Expand Down
12 changes: 10 additions & 2 deletions widgets/price-ranges/price-ranges.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,17 @@ function priceRanges({
separator: 'to'
},
autoHideContainer = true
}) {
} = {}) {
let containerNode = utils.getContainerNode(container);
let usage = 'Usage: priceRanges({container, attributeName, [cssClasses.{root,header,body,list,item,active,link,form,label,input,currency,separator,button,footer}, templates.{header,item,footer}, labels.{currency,separator,button}, autoHideContainer]})';
const usage = `Usage:
priceRanges({
container,
attributeName,
[ cssClasses.{root,header,body,list,item,active,link,form,label,input,currency,separator,button,footer}={} ],
[ templates.{header,item,footer}={} ],
[ labels.{currency,separator,button}={currency: '$', button: 'Go', separator: 'to'} ],
[ autoHideContainer=true ]
})`;

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

0 comments on commit 89601d7

Please sign in to comment.