Skip to content

Commit

Permalink
Merge pull request react-bootstrap#789 from AlexKVal/getDOMNode
Browse files Browse the repository at this point in the history
Use React.findDOMNode()
  • Loading branch information
AlexKVal committed Jun 4, 2015
2 parents 5177602 + 31d9eb2 commit eeb7796
Show file tree
Hide file tree
Showing 34 changed files with 229 additions and 231 deletions.
10 changes: 5 additions & 5 deletions test/AlertSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Alert', function () {
Message
</Alert>
);
assert.ok(instance.getDOMNode().className.match(/\balert\b/));
assert.ok(React.findDOMNode(instance).className.match(/\balert\b/));
});

it('Should have dismissable style with onDismiss', function () {
Expand All @@ -28,7 +28,7 @@ describe('Alert', function () {
Message
</Alert>
);
assert.ok(instance.getDOMNode().className.match(/\balert-dismissable\b/));
assert.ok(React.findDOMNode(instance).className.match(/\balert-dismissable\b/));
});

it('Should call onDismiss callback on dismiss click', function (done) {
Expand All @@ -40,7 +40,7 @@ describe('Alert', function () {
Message
</Alert>
);
ReactTestUtils.Simulate.click(instance.getDOMNode().children[0]);
ReactTestUtils.Simulate.click(React.findDOMNode(instance).children[0]);
});

it('Should call onDismiss callback on dismissAfter time', function (done) {
Expand All @@ -60,7 +60,7 @@ describe('Alert', function () {
Message
</Alert>
);
assert.ok(instance.getDOMNode().className.match(/\balert-\w+\b/));
assert.ok(React.findDOMNode(instance).className.match(/\balert-\w+\b/));
});

it('Should have use bsStyle class', function () {
Expand All @@ -69,6 +69,6 @@ describe('Alert', function () {
Message
</Alert>
);
assert.ok(instance.getDOMNode().className.match(/\balert-danger\b/));
assert.ok(React.findDOMNode(instance).className.match(/\balert-danger\b/));
});
});
10 changes: 5 additions & 5 deletions test/BadgeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Badge', function () {
Content
</Badge>
);
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbadge\b/));
});

it('Should have a badge using a number', function () {
Expand All @@ -28,7 +28,7 @@ describe('Badge', function () {
{count}
</Badge>
);
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbadge\b/));
});

it('Should have a badge using a a mix of content', function () {
Expand All @@ -38,7 +38,7 @@ describe('Badge', function () {
£{count}
</Badge>
);
assert.ok(instance.getDOMNode().className.match(/\bbadge\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbadge\b/));
});

it('Should have a badge class pulled right', function () {
Expand All @@ -47,13 +47,13 @@ describe('Badge', function () {
Content
</Badge>
);
assert.ok(instance.getDOMNode().className.match(/\bpull-right\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bpull-right\b/));
});

it('Should not have a badge class when empty', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Badge />
);
assert.notOk(instance.getDOMNode().className.match(/\bbadge\b/));
assert.notOk(React.findDOMNode(instance).className.match(/\bbadge\b/));
});
});
12 changes: 6 additions & 6 deletions test/ButtonGroupSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ describe('ButtonGroup', function () {
</Button>
</ButtonGroup>
);
assert.equal(instance.getDOMNode().nodeName, 'DIV');
assert.ok(instance.getDOMNode().className.match(/\bbtn-group\b/));
assert.equal(React.findDOMNode(instance).nodeName, 'DIV');
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-group\b/));
});

it('Should add size', function () {
Expand All @@ -25,7 +25,7 @@ describe('ButtonGroup', function () {
</Button>
</ButtonGroup>
);
assert.ok(instance.getDOMNode().className.match(/\bbtn-group-lg\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-group-lg\b/));
});

it('Should add vertical variation', function () {
Expand All @@ -36,7 +36,7 @@ describe('ButtonGroup', function () {
</Button>
</ButtonGroup>
);
assert.equal(instance.getDOMNode().className.trim(), 'btn-group-vertical');
assert.equal(React.findDOMNode(instance).className.trim(), 'btn-group-vertical');
});

it('Should add block variation', function () {
Expand All @@ -47,7 +47,7 @@ describe('ButtonGroup', function () {
</Button>
</ButtonGroup>
);
assert.ok(instance.getDOMNode().className.match(/\bbtn-block\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-block\b/));
});

it('Should warn about block without vertical', function () {
Expand All @@ -69,6 +69,6 @@ describe('ButtonGroup', function () {
</Button>
</ButtonGroup>
);
assert.ok(instance.getDOMNode().className.match(/\bbtn-group-justified\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-group-justified\b/));
});
});
6 changes: 3 additions & 3 deletions test/ButtonInputSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('ButtonInput', () =>{
<ButtonInput value="button" bsStyle="danger" wrapperClassName="test" />
);

const node = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input').getDOMNode();
const node = React.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input'));
assert.equal(node.getAttribute('type'), 'button');
assert.equal(node.getAttribute('class'), 'btn btn-danger');
});
Expand All @@ -19,14 +19,14 @@ describe('ButtonInput', () =>{
<ButtonInput value="button" type="reset" />
);

let node = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input').getDOMNode();
let node = React.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input'));
assert.equal(node.getAttribute('type'), 'reset');

instance = ReactTestUtils.renderIntoDocument(
<ButtonInput value="button" type="submit" />
);

node = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input').getDOMNode();
node = React.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'input'));
assert.equal(node.getAttribute('type'), 'submit');
});

Expand Down
42 changes: 21 additions & 21 deletions test/ButtonSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Button', function () {
Title
</Button>
);
assert.equal(instance.getDOMNode().nodeName, 'BUTTON');
assert.equal(React.findDOMNode(instance).nodeName, 'BUTTON');
});

it('Should output a component with button classes', function () {
Expand All @@ -18,8 +18,8 @@ describe('Button', function () {
Title
</Button>
);
assert.equal(instance.getDOMNode().nodeName, 'INPUT');
assert.equal(instance.getDOMNode().getAttribute('class'), 'btn btn-default');
assert.equal(React.findDOMNode(instance).nodeName, 'INPUT');
assert.equal(React.findDOMNode(instance).getAttribute('class'), 'btn btn-default');
});

it('Should have type=button by default', function () {
Expand All @@ -28,7 +28,7 @@ describe('Button', function () {
Title
</Button>
);
assert.equal(instance.getDOMNode().getAttribute('type'), 'button');
assert.equal(React.findDOMNode(instance).getAttribute('type'), 'button');
});

it('Should show the type if passed one', function () {
Expand All @@ -37,7 +37,7 @@ describe('Button', function () {
Title
</Button>
);
assert.equal(instance.getDOMNode().getAttribute('type'), 'submit');
assert.equal(React.findDOMNode(instance).getAttribute('type'), 'submit');
});

it('Should output an anchor if called with a href', function () {
Expand All @@ -47,8 +47,8 @@ describe('Button', function () {
Title
</Button>
);
assert.equal(instance.getDOMNode().nodeName, 'A');
assert.equal(instance.getDOMNode().getAttribute('href'), href);
assert.equal(React.findDOMNode(instance).nodeName, 'A');
assert.equal(React.findDOMNode(instance).getAttribute('href'), href);
});

it('Should output an input if called with a href and an input component', function () {
Expand All @@ -58,8 +58,8 @@ describe('Button', function () {
Title
</Button>
);
assert.equal(instance.getDOMNode().nodeName, 'INPUT');
assert.equal(instance.getDOMNode().getAttribute('href'), href);
assert.equal(React.findDOMNode(instance).nodeName, 'INPUT');
assert.equal(React.findDOMNode(instance).getAttribute('href'), href);
});

it('Should output an anchor if called with a target', function () {
Expand All @@ -69,8 +69,8 @@ describe('Button', function () {
Title
</Button>
);
assert.equal(instance.getDOMNode().nodeName, 'A');
assert.equal(instance.getDOMNode().getAttribute('target'), target);
assert.equal(React.findDOMNode(instance).nodeName, 'A');
assert.equal(React.findDOMNode(instance).getAttribute('target'), target);
});

it('Should call onClick callback', function (done) {
Expand All @@ -82,7 +82,7 @@ describe('Button', function () {
Title
</Button>
);
ReactTestUtils.Simulate.click(instance.getDOMNode());
ReactTestUtils.Simulate.click(React.findDOMNode(instance));
});

it('Should be disabled', function () {
Expand All @@ -91,7 +91,7 @@ describe('Button', function () {
Title
</Button>
);
assert.ok(instance.getDOMNode().disabled);
assert.ok(React.findDOMNode(instance).disabled);
});

it('Should be disabled link', function () {
Expand All @@ -100,7 +100,7 @@ describe('Button', function () {
Title
</Button>
);
assert.ok(instance.getDOMNode().className.match(/\bdisabled\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bdisabled\b/));
});

it('Should have block class', function () {
Expand All @@ -109,7 +109,7 @@ describe('Button', function () {
Title
</Button>
);
assert.ok(instance.getDOMNode().className.match(/\bbtn-block\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-block\b/));
});

it('Should apply bsStyle class', function () {
Expand All @@ -118,7 +118,7 @@ describe('Button', function () {
Title
</Button>
);
assert.ok(instance.getDOMNode().className.match(/\bbtn-danger\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-danger\b/));
});

it('Should honour additional classes passed in, adding not overriding', function () {
Expand All @@ -127,8 +127,8 @@ describe('Button', function () {
Title
</Button>
);
assert.ok(instance.getDOMNode().className.match(/\bbob\b/));
assert.ok(instance.getDOMNode().className.match(/\bbtn-danger\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbob\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bbtn-danger\b/));
});

it('Should default to bsStyle="default"', function () {
Expand All @@ -146,7 +146,7 @@ describe('Button', function () {
Title
</Button>
);
assert.ok(instance.getDOMNode().className.match(/\bactive\b/));
assert.ok(React.findDOMNode(instance).className.match(/\bactive\b/));
});

it('Should render an anchor in a list item when in a nav', function () {
Expand All @@ -156,7 +156,7 @@ describe('Button', function () {
</Button>
);

let li = instance.getDOMNode();
let li = React.findDOMNode(instance);
let anchor = ReactTestUtils.findRenderedDOMComponentWithTag(instance, 'a');
assert.equal(li.nodeName, 'LI');
assert.ok(li.className.match(/\bactive\b/));
Expand All @@ -170,7 +170,7 @@ describe('Button', function () {
</Button>
);

let anchor = instance.getDOMNode();
let anchor = React.findDOMNode(instance);
assert.equal(anchor.nodeName, 'A');
assert.ok(anchor.getAttribute('href'), '#');
});
Expand Down
7 changes: 4 additions & 3 deletions test/ButtonToolbarSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ describe('ButtonToolbar', function () {
</ButtonGroup>
</ButtonToolbar>
);
assert.equal(instance.getDOMNode().nodeName, 'DIV');
assert.ok(instance.getDOMNode().className.match(/\bbtn-toolbar\b/));
assert.equal(instance.getDOMNode().getAttribute('role'), 'toolbar');
let node = React.findDOMNode(instance);
assert.equal(node.nodeName, 'DIV');
assert.ok(node.className.match(/\bbtn-toolbar\b/));
assert.equal(node.getAttribute('role'), 'toolbar');
});
});
6 changes: 3 additions & 3 deletions test/ColSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Col', function () {
<Col xsOffset={0} smOffset={0} mdOffset={0} lgOffset={0} />
);

let instanceClassName = instance.getDOMNode().className;
let instanceClassName = React.findDOMNode(instance).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/));
Expand All @@ -20,7 +20,7 @@ describe('Col', function () {
<Col xsPull={0} smPull={0} mdPull={0} lgPull={0} />
);

let instanceClassName = instance.getDOMNode().className;
let instanceClassName = React.findDOMNode(instance).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/));
Expand All @@ -32,7 +32,7 @@ describe('Col', function () {
<Col xsPush={0} smPush={0} mdPush={0} lgPush={0} />
);

let instanceClassName = instance.getDOMNode().className;
let instanceClassName = React.findDOMNode(instance).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/));
Expand Down
2 changes: 1 addition & 1 deletion test/CollapsibleMixinSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('CollapsibleMixin', function () {
mixins: [CollapsibleMixin],

getCollapsibleDOMNode(){
return this.refs.panel.getDOMNode();
return React.findDOMNode(this.refs.panel);
},

getCollapsibleDimensionValue(){
Expand Down
Loading

0 comments on commit eeb7796

Please sign in to comment.