From 99b8193ce7a33f26ae08667d354f26ed1ef2f3dd Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 17 Sep 2019 14:33:32 -0600 Subject: [PATCH] Use the new ShallowRenderer over ReactTestUtils Mostly because the ReactTestUtils renderer doesn't exist anymore. --- package.json | 1 + .../views/elements/MemberEventListSummary-test.js | 4 ++-- test/test-utils.js | 5 +++++ yarn.lock | 15 +++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 070abf352d..0e41d4c38a 100644 --- a/package.json +++ b/package.json @@ -150,6 +150,7 @@ "matrix-mock-request": "^1.2.3", "matrix-react-test-utils": "^0.2.2", "mocha": "^5.0.5", + "react-test-renderer": "^16.9.0", "require-json": "0.0.1", "rimraf": "^2.4.3", "sinon": "^5.0.7", diff --git a/test/components/views/elements/MemberEventListSummary-test.js b/test/components/views/elements/MemberEventListSummary-test.js index d1e112735d..09a4739f06 100644 --- a/test/components/views/elements/MemberEventListSummary-test.js +++ b/test/components/views/elements/MemberEventListSummary-test.js @@ -112,7 +112,7 @@ describe('MemberEventListSummary', function() { threshold: 3, }; - const renderer = ReactTestUtils.createRenderer(); + const renderer = testUtils.getRenderer(); renderer.render(); const result = renderer.getRenderOutput(); @@ -134,7 +134,7 @@ describe('MemberEventListSummary', function() { threshold: 3, }; - const renderer = ReactTestUtils.createRenderer(); + const renderer = testUtils.getRenderer(); renderer.render(); const result = renderer.getRenderOutput(); diff --git a/test/test-utils.js b/test/test-utils.js index f60cab3bc2..ff800132b9 100644 --- a/test/test-utils.js +++ b/test/test-utils.js @@ -9,6 +9,7 @@ import dis from '../src/dispatcher'; import jssdk from 'matrix-js-sdk'; import {makeType} from "../src/utils/TypeUtils"; import {ValidatedServerConfig} from "../src/utils/AutoDiscoveryUtils"; +import ShallowRenderer from 'react-test-renderer/shallow'; const MatrixEvent = jssdk.MatrixEvent; /** @@ -31,6 +32,10 @@ export function beforeEach(context) { console.log(new Array(1 + desc.length).join("=")); } +export function getRenderer() { + // Old: ReactTestUtils.createRenderer(); + return new ShallowRenderer(); +} /** * Stub out the MatrixClient, and configure the MatrixClientPeg object to diff --git a/yarn.lock b/yarn.lock index 712de0b2b4..4789b22041 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6404,6 +6404,11 @@ react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4: resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16" integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA== +react-is@^16.9.0: + version "16.9.0" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.9.0.tgz#21ca9561399aad0ff1a7701c01683e8ca981edcb" + integrity sha512-tJBzzzIgnnRfEm046qRcURvwQnZVXmuCbscxUO5RWrGTXpon2d4c8mI0D8WE6ydVIm29JiLB6+RslkIvym9Rjw== + react-lifecycles-compat@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362" @@ -6431,6 +6436,16 @@ react-redux@^5.0.6: react-is "^16.6.0" react-lifecycles-compat "^3.0.0" +react-test-renderer@^16.9.0: + version "16.9.0" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.9.0.tgz#7ed657a374af47af88f66f33a3ef99c9610c8ae9" + integrity sha512-R62stB73qZyhrJo7wmCW9jgl/07ai+YzvouvCXIJLBkRlRqLx4j9RqcLEAfNfU3OxTGucqR2Whmn3/Aad6L3hQ== + dependencies: + object-assign "^4.1.1" + prop-types "^15.6.2" + react-is "^16.9.0" + scheduler "^0.15.0" + react-transition-group@^1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/react-transition-group/-/react-transition-group-1.2.1.tgz#e11f72b257f921b213229a774df46612346c7ca6"