Skip to content

Commit

Permalink
Merge pull request react-bootstrap#438 from aforty/patch-1
Browse files Browse the repository at this point in the history
Col Push/Pull/Offset value zero support
  • Loading branch information
mtscout6 committed Mar 5, 2015
2 parents 851e4d9 + 3b6ba7a commit 96cc2fb
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Col.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ var Col = React.createClass({

prop = size + 'Offset';
classPart = size + '-offset-';
if (this.props[prop]) {
if (this.props[prop] >= 0) {
classes['col-' + classPart + this.props[prop]] = true;
}

prop = size + 'Push';
classPart = size + '-push-';
if (this.props[prop]) {
if (this.props[prop] >= 0) {
classes['col-' + classPart + this.props[prop]] = true;
}

prop = size + 'Pull';
classPart = size + '-pull-';
if (this.props[prop]) {
if (this.props[prop] >= 0) {
classes['col-' + classPart + this.props[prop]] = true;
}
}, this);
Expand All @@ -71,4 +71,4 @@ var Col = React.createClass({
}
});

module.exports = Col;
module.exports = Col;
43 changes: 43 additions & 0 deletions test/ColSpec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*global describe, it, assert */

var React = require('react');
var ReactTestUtils = require('react/lib/ReactTestUtils');
var Col = require('../lib/Col');

describe('Col', function () {
it('Should set Offset of zero', function () {
var instance = ReactTestUtils.renderIntoDocument(
<Col xsOffset={0} smOffset={0} mdOffset={0} lgOffset={0} />
);

var instanceClassName = instance.getDOMNode().className;
assert.ok(instanceClassName.match(/\bcol-xs-offset-0\b/));
assert.ok(instanceClassName.match(/\bcol-sm-offset-0\b/));
assert.ok(instanceClassName.match(/\bcol-md-offset-0\b/));
assert.ok(instanceClassName.match(/\bcol-lg-offset-0\b/));
});

it('Should set Pull of zero', function () {
var instance = ReactTestUtils.renderIntoDocument(
<Col xsPull={0} smPull={0} mdPull={0} lgPull={0} />
);

var instanceClassName = instance.getDOMNode().className;
assert.ok(instanceClassName.match(/\bcol-xs-pull-0\b/));
assert.ok(instanceClassName.match(/\bcol-sm-pull-0\b/));
assert.ok(instanceClassName.match(/\bcol-md-pull-0\b/));
assert.ok(instanceClassName.match(/\bcol-lg-pull-0\b/));
});

it('Should set Push of zero', function () {
var instance = ReactTestUtils.renderIntoDocument(
<Col xsPush={0} smPush={0} mdPush={0} lgPush={0} />
);

var instanceClassName = instance.getDOMNode().className;
assert.ok(instanceClassName.match(/\bcol-xs-push-0\b/));
assert.ok(instanceClassName.match(/\bcol-sm-push-0\b/));
assert.ok(instanceClassName.match(/\bcol-md-push-0\b/));
assert.ok(instanceClassName.match(/\bcol-lg-push-0\b/));
});
});

0 comments on commit 96cc2fb

Please sign in to comment.