Skip to content

Commit

Permalink
Upgrade React to v16 for dev & test (#547)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcjordan authored Jul 1, 2020
1 parent cfe3da8 commit adc9ddd
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 177 deletions.
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();
sandbox = sinon.sandbox.create();
})

after(function () {
clock.restore();
})
var 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

0 comments on commit adc9ddd

Please sign in to comment.