Skip to content

Commit

Permalink
update tests to use react-addons-test-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
rolyatmax committed Oct 27, 2015
1 parent 9b5bae5 commit bbde573
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 28 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"karma-webpack": "^1.7.0",
"object.assign": "^1.1.1",
"phantomjs": "^1.9.18",
"react-addons-test-utils": "^0.14.0",
"timekeeper": "0.0.5",
"transform-loader": "^0.2.1",
"underscore": "^1.8.3",
Expand Down
6 changes: 3 additions & 3 deletions src/calendar/tests/CalendarDate.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react/addons';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import moment from 'moment';
import _ from 'underscore';

Expand All @@ -8,7 +9,6 @@ import CalendarDatePeriod from '../CalendarDatePeriod';
import CalendarHighlight from '../CalendarHighlight';
import CalendarSelection from '../CalendarSelection';

const TestUtils = React.addons.TestUtils;

describe('The CalendarDate Component', function () {

Expand Down Expand Up @@ -61,7 +61,7 @@ describe('The CalendarDate Component', function () {
const renderedTable = TestUtils.renderIntoDocument(<table>
<tbody>{getCalendarDate(props)}</tbody>
</table>);
this.renderedComponent = TestUtils.findRenderedDOMComponentWithTag(renderedTable, 'td');
this.renderedComponent = renderedTable.querySelector('td');
};

this.spyCx = spyOn(CalendarDate.prototype.__reactAutoBindMap, 'cx').and.callFake((data) => {
Expand Down
4 changes: 2 additions & 2 deletions src/calendar/tests/CalendarDatePeriod.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react/addons';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import CalendarDatePeriod from '../CalendarDatePeriod';

const TestUtils = React.addons.TestUtils;

describe('The CalendarDatePeriod Component', function () {
beforeEach(function () {
Expand Down
4 changes: 2 additions & 2 deletions src/calendar/tests/CalendarHighlight.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react/addons';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import CalendarHighlight from '../CalendarHighlight';

const TestUtils = React.addons.TestUtils;

describe('The CalendarHighlight Component', function () {
beforeEach(function () {
Expand Down
5 changes: 2 additions & 3 deletions src/calendar/tests/CalendarMonth.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import React from 'react/addons';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import CalendarMonth from '../CalendarMonth';
import CalendarDate from '../CalendarDate';
import moment from 'moment';
import {} from 'moment-range';
import _ from 'underscore';


const TestUtils = React.addons.TestUtils;

describe('The CalendarMonth Component', function () {

beforeEach(function () {
Expand Down
4 changes: 2 additions & 2 deletions src/calendar/tests/CalendarSelection.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react/addons';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import CalendarSelection from '../CalendarSelection';

const TestUtils = React.addons.TestUtils;

describe('The CalendarSelection Component', function () {
beforeEach(function () {
Expand Down
4 changes: 2 additions & 2 deletions src/tests/DateRangePicker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import 'moment-range';
import isMomentRange from '../utils/isMomentRange';
import areMomentRangesEqual from '../utils/areMomentRangesEqual';
import Immutable from 'immutable';
import React from 'react/addons';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import _ from 'underscore';

const TestUtils = React.addons.TestUtils;

describe('The DateRangePicker component', function () {

Expand Down
21 changes: 11 additions & 10 deletions src/tests/Legend.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react/addons';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Legend from '../Legend';
import _ from 'underscore';


const TestUtils = React.addons.TestUtils;

describe('The Legend component', function () {

beforeEach(function () {
Expand All @@ -25,7 +24,8 @@ describe('The Legend component', function () {
};

this.useDocumentRenderer = (props) => {
this.renderedComponent = TestUtils.renderIntoDocument(getLegend(props));
const domComponent = TestUtils.renderIntoDocument(<div>{getLegend(props)}</div>);
this.renderedComponent = domComponent.childNodes[0];
};

this.spyCx = spyOn(Legend.prototype.__reactAutoBindMap, 'cx').and.callFake( (data) => {
Expand Down Expand Up @@ -62,12 +62,13 @@ describe('The Legend component', function () {
},
},
});
var lis = TestUtils.scryRenderedDOMComponentsWithTag(this.renderedComponent, 'li');
expect(lis.length).toBe(3);
var spans = TestUtils.scryRenderedDOMComponentsWithTag(lis[1], 'span');

expect(this.renderedComponent.childNodes.length).toBe(3);

var spans = this.renderedComponent.childNodes[1].querySelectorAll('span');
expect(spans.length).toBe(2);
expect(spans[0].getDOMNode().style.backgroundColor).toBe('blue');
expect(spans[1].getDOMNode().textContent).toBe('abc');
});

expect(spans[0].style.backgroundColor).toBe('blue');
expect(spans[1].textContent).toBe('abc');
});
});
5 changes: 2 additions & 3 deletions src/tests/PaginationArrow.spec.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react/addons';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import _ from 'underscore';

import PaginationArrow from '../PaginationArrow';

const TestUtils = React.addons.TestUtils;

describe('The Pagination Arrow component', function () {

beforeEach(function () {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tests/BemMixin.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react/addons';
import React from 'react';

import BemMixin from '../BemMixin';

Expand Down

0 comments on commit bbde573

Please sign in to comment.