Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade React to 16 for dev & tests #547

Merged
merged 2 commits into from
Jul 1, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
"null-loader": "3.0.0",
"postcss": "7.0.16",
"postcss-custom-properties": "6.3.1",
"react": "15.6.2",
"react-addons-test-utils": "15.6.2",
"react": "16.13.1",
"react-dimensions": "1.3.1",
"react-docgen": "4.1.1",
"react-dom": "15.6.2",
"react-dom": "16.13.1",
"react-test-renderer": "^16.13.1",
"react-tools": "0.13.3",
"react-tooltip": "3.11.1",
"sinon": "7.4.2",
"sinon": "9.0.2",
"style-loader": "1.0.0",
"uglifyjs-webpack-plugin": "^2.2.0",
"url-loader": "2.1.0",
Expand Down
7 changes: 4 additions & 3 deletions test/FixedDataTableRoot-test.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/**
* Copyright Schrodinger, LLC
*/

import { assert } from 'chai';
import sinon from 'sinon';
import React from 'react';
import ReactDOM from 'react-dom';
import Scrollbar from 'Scrollbar';
import { Table, Column } from '../src/FixedDataTableRoot';
import * as requestAnimation from '../src/vendor_upstream/core/requestAnimationFramePolyfill';
import {
import {
createRenderer,
} from 'react-test-renderer/shallow';
import {
findRenderedComponentWithType,
findRenderedDOMComponentWithClass,
isElement,
} from 'react-addons-test-utils';
} from 'react-dom/test-utils';

describe('FixedDataTableRoot', function() {
describe('render ', function() {
Expand Down
36 changes: 11 additions & 25 deletions test/ReactTouchHandler-test.js
Original file line number Diff line number Diff line change
@@ -1,46 +1,34 @@
/**
* Copyright Schrodinger, LLC
*/

import React from 'react';
import ReactTouchHandler from '../src/ReactTouchHandler';
import sinon from 'sinon';
import { assert } from 'chai';
import { createRenderer, isElement } from 'react-addons-test-utils';

describe('ReactTouchHandler', function() {
var clock, sandbox, requestAnimationFramePolyfillSpy;

before(function () {
clock = sinon.useFakeTimers();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since all tests share a sandbox I moved this down to the test which actually uses it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: clock is defined below in the actual test, so we don't need the declaration here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, will do

sandbox = sinon.sandbox.create();
})

after(function () {
clock.restore();
})
var clock, requestAnimationFramePolyfillSpy;

beforeEach(function() {
requestAnimationFramePolyfillSpy = sandbox.spy();
requestAnimationFramePolyfillSpy = sinon.spy();
ReactTouchHandler.__Rewire__('requestAnimationFramePolyfill', requestAnimationFramePolyfillSpy);
});

afterEach(function() {
sandbox.restore();
sinon.restore();
ReactTouchHandler.__ResetDependency__('requestAnimationFramePolyfill');
});

describe('onTouchStart', function() {
var fakeEvent;
beforeEach(function() {
ReactTouchHandler.prototype._track = sandbox.spy();
ReactTouchHandler.prototype._track = sinon.spy();
fakeEvent = {
touches: [{
pageX: 121,
pageY: 312
}],
preventDefault: sandbox.spy(),
stopPropagation: sandbox.spy()
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
};
});

Expand Down Expand Up @@ -72,6 +60,8 @@ describe('ReactTouchHandler', function() {
});

it('should start new interval', function() {
const clock = sinon.useFakeTimers();

// --- Run Test ---
var reactTouchHandler = new ReactTouchHandler(() => {}, () => {}, () => {}, false, false);
reactTouchHandler.onTouchStart(fakeEvent);
Expand All @@ -86,21 +76,17 @@ describe('ReactTouchHandler', function() {
var fakeEvent, clearIntervalSpy;

beforeEach(function() {
clearIntervalSpy = sandbox.spy(global || window, 'clearInterval')
clearIntervalSpy = sinon.spy(global || window, 'clearInterval')
fakeEvent = {
touches: [{
pageX: 121,
pageY: 312
}],
preventDefault: sandbox.spy(),
stopPropagation: sandbox.spy()
preventDefault: sinon.spy(),
stopPropagation: sinon.spy()
};
});

afterEach(function() {

});

it('should stop event propagation if flag is true', function() {
// --- Run Test ---
var reactTouchHandler = new ReactTouchHandler(() => {}, () => {}, () => {}, false, true);
Expand Down
9 changes: 3 additions & 6 deletions test/reducers/computeRenderedRows-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,8 @@ describe('computeRenderedRows', function() {
});

describe('computeRenderedRows', function() {
let sandbox;
let oldState;
beforeEach(function() {
sandbox = sinon.sandbox.create();

const initialStoredHeights = {};
for (let rowIdx = 0; rowIdx < 80; rowIdx++) {
initialStoredHeights[rowIdx] = 125;
Expand All @@ -52,7 +49,7 @@ describe('computeRenderedRows', function() {
});

afterEach(function() {
sandbox.restore();
sinon.restore();
});

it('should update rowBufferSet & row heights for buffered rows', function() {
Expand Down Expand Up @@ -195,14 +192,14 @@ describe('computeRenderedRows', function() {
};
oldState.rowSettings.rowHeightGetter = () => 200;

const rowOffsetIntervalTreeMock = sandbox.mock(PrefixIntervalTree.prototype);
const rowOffsetIntervalTreeMock = sinon.mock(PrefixIntervalTree.prototype);
oldState.rowOffsetIntervalTree = PrefixIntervalTree.uniform(80, 125);
for (let rowIdx = 13; rowIdx < 21; rowIdx++) {
rowOffsetIntervalTreeMock.expects('set').once().withArgs(rowIdx, 200);
}

const newState = computeRenderedRows(oldState, scrollAnchor);
sandbox.verify();
rowOffsetIntervalTreeMock.verify();

let priorHeight = 1625;
const expectedRowOffsets = {};
Expand Down
Loading