[Codemod] Rename react unsafe lifecycles (#8143)

* [Codemod] Rename react unsafe lifecycles

* Fix lint errors

* [Codemod] Rename react unsafe lifecycles

* Fix lint errors
This commit is contained in:
Erik Ritter
2019-09-03 14:13:58 -07:00
committed by Grace Guo
parent ee24539bd2
commit 436261e703
37 changed files with 437 additions and 460 deletions

View File

@@ -145,7 +145,7 @@ describe('AlteredSliceTag', () => {
};
newProps.currentFormData.beta = 10;
wrapper = shallow(<AlteredSliceTag {...props} />);
wrapper.instance().componentWillReceiveProps(newProps);
wrapper.instance().UNSAFE_componentWillReceiveProps(newProps);
const newDiffs = wrapper.instance().state.diffs;
const expectedBeta = { before: undefined, after: 10 };
expect(newDiffs.beta).toEqual(expectedBeta);
@@ -153,7 +153,7 @@ describe('AlteredSliceTag', () => {
it('does not set new state when props are the same', () => {
const currentDiff = wrapper.instance().state.diffs;
wrapper.instance().componentWillReceiveProps(props);
wrapper.instance().UNSAFE_componentWillReceiveProps(props);
// Check equal references
expect(wrapper.instance().state.diffs).toBe(currentDiff);
});

View File

@@ -160,7 +160,7 @@ describe('Dashboard', () => {
it('should call addSliceToDashboard if a new slice is added to the layout', () => {
const wrapper = setup();
const spy = sinon.spy(props.actions, 'addSliceToDashboard');
wrapper.instance().componentWillReceiveProps({
wrapper.instance().UNSAFE_componentWillReceiveProps({
...props,
layout: layoutWithExtraChart,
});
@@ -174,7 +174,7 @@ describe('Dashboard', () => {
const nextLayout = { ...layoutWithExtraChart };
delete nextLayout[1001];
wrapper.instance().componentWillReceiveProps({
wrapper.instance().UNSAFE_componentWillReceiveProps({
...props,
layout: nextLayout,
});

View File

@@ -109,7 +109,7 @@ describe('SliceAdder', () => {
});
it('fetch slices should update state', () => {
wrapper.instance().componentWillReceiveProps({
wrapper.instance().UNSAFE_componentWillReceiveProps({
...props,
lastUpdated: new Date().getTime(),
});
@@ -122,7 +122,7 @@ describe('SliceAdder', () => {
});
it('select slices should update state', () => {
wrapper.instance().componentWillReceiveProps({
wrapper.instance().UNSAFE_componentWillReceiveProps({
...props,
selectedSliceIds: [127],
});

View File

@@ -70,7 +70,7 @@ describe('ResultSet', () => {
beforeEach(() => {
clearQuerySpy.reset();
fetchQuerySpy.reset();
spy = sinon.spy(ResultSet.prototype, 'componentWillReceiveProps');
spy = sinon.spy(ResultSet.prototype, 'UNSAFE_componentWillReceiveProps');
});
afterEach(() => {
spy.restore();