Skip to content

Commit 163dea5

Browse files
authored
Merge pull request code-dot-org#26720 from code-dot-org/remove-react-applab-crosshair-overlay
Removed react-test-utils from AppLabCrosshairOverlayTest.js
2 parents 85aa7ae + 9cf8339 commit 163dea5

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed
Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import {expect} from '../../util/configuredChai';
22
import sinon from 'sinon';
33
import React from 'react';
4-
import ReactTestUtils from 'react-addons-test-utils';
4+
import {shallow} from 'enzyme';
55
import AppLabCrosshairOverlay from '@cdo/apps/applab/AppLabCrosshairOverlay';
6-
import CrosshairOverlay from '@cdo/apps/templates/CrosshairOverlay';
76
// ES5-style require necessary to stub gridUtils.draggedElementDropPoint
87
var gridUtils = require('@cdo/apps/applab/gridUtils');
98

@@ -12,10 +11,9 @@ describe('AppLabCrosshairOverlay', () => {
1211
TEST_APP_HEIGHT = Math.random(),
1312
TEST_MOUSE_X = Math.random(),
1413
TEST_MOUSE_Y = Math.random();
15-
var renderer, stubDraggedElementDropPoint;
14+
var stubDraggedElementDropPoint;
1615

1716
beforeEach(() => {
18-
renderer = ReactTestUtils.createRenderer();
1917
stubDraggedElementDropPoint = sinon.stub(gridUtils, 'draggedElementDropPoint');
2018
});
2119

@@ -25,45 +23,43 @@ describe('AppLabCrosshairOverlay', () => {
2523

2624
it('renders to CrosshairOverlay with unmodified properties when not dragging', () => {
2725
stubDraggedElementDropPoint.returns(null);
28-
renderer.render(
26+
var element = shallow(
2927
<AppLabCrosshairOverlay
3028
width={TEST_APP_WIDTH}
3129
height={TEST_APP_HEIGHT}
3230
mouseX={TEST_MOUSE_X}
3331
mouseY={TEST_MOUSE_Y}
3432
/>
3533
);
36-
const result = renderer.getRenderOutput();
37-
expect(result).to.deep.equal(
38-
<CrosshairOverlay
39-
width={TEST_APP_WIDTH}
40-
height={TEST_APP_HEIGHT}
41-
mouseX={TEST_MOUSE_X}
42-
mouseY={TEST_MOUSE_Y}
43-
/>
44-
);
34+
35+
var overlay = element.find('CrosshairOverlay');
36+
var props = overlay.props();
37+
expect(overlay.length).to.equal(1);
38+
expect(props.width).to.equal(TEST_APP_WIDTH);
39+
expect(props.height).to.equal(TEST_APP_HEIGHT);
40+
expect(props.mouseX).to.equal(TEST_MOUSE_X);
41+
expect(props.mouseY).to.equal(TEST_MOUSE_Y);
4542
});
4643

4744
it('renders to CrosshairOverlay with overridden mouse coordinates when dragging', () => {
4845
const dropPointX = 42;
4946
const dropPointY = 43;
5047
stubDraggedElementDropPoint.returns({ left: dropPointX, top: dropPointY });
51-
renderer.render(
48+
var element = shallow(
5249
<AppLabCrosshairOverlay
5350
width={TEST_APP_WIDTH}
5451
height={TEST_APP_HEIGHT}
5552
mouseX={TEST_MOUSE_X}
5653
mouseY={TEST_MOUSE_Y}
5754
/>
5855
);
59-
const result = renderer.getRenderOutput();
60-
expect(result).to.deep.equal(
61-
<CrosshairOverlay
62-
width={TEST_APP_WIDTH}
63-
height={TEST_APP_HEIGHT}
64-
mouseX={dropPointX}
65-
mouseY={dropPointY}
66-
/>
67-
);
56+
57+
var overlay = element.find('CrosshairOverlay');
58+
var props = overlay.props();
59+
expect(overlay.length).to.equal(1);
60+
expect(props.width).to.equal(TEST_APP_WIDTH);
61+
expect(props.height).to.equal(TEST_APP_HEIGHT);
62+
expect(props.mouseX).to.equal(dropPointX);
63+
expect(props.mouseY).to.equal(dropPointY);
6864
});
6965
});

0 commit comments

Comments
 (0)