Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 5f02d4d

Browse files
committed
Update devtools-components to React 16.
Needed a new version of Enzyme and some minor changes in tests.
1 parent 8cef679 commit 5f02d4d

File tree

4 files changed

+1490
-1313
lines changed

4 files changed

+1490
-1313
lines changed

packages/devtools-components/package.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,40 @@
1313
"license": "MPL-2.0",
1414
"dependencies": {
1515
"prop-types": "^15.6.0",
16+
"react": "^16.2.0",
17+
"react-dom": "^16.2.0",
1618
"react-dom-factories": "^1.0.2",
1719
"svg-inline-loader": "^0.8.0",
1820
"svg-inline-react": "^3.0.0"
1921
},
2022
"devDependencies": {
21-
"@storybook/react": "^3.2.13",
22-
"babel-jest": "^20.0.3",
23+
"@storybook/react": "^3.3.14",
24+
"babel-jest": "^22.4.1",
2325
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
2426
"babel-preset-react": "^6.24.1",
2527
"devtools-license-check": "^0.5.1",
26-
"devtools-launchpad": "^0.0.100",
27-
"enzyme": "^2.8.2",
28+
"enzyme": "^3.3.0",
29+
"enzyme-adapter-react-16": "^1.1.1",
2830
"eslint": "^3.12.0",
2931
"eslint-plugin-mozilla": "0.2.3",
3032
"fs-extra": "^2.0.0",
31-
"jest": "^20.0.4",
32-
"jest-cli": "^20.0.4",
33+
"jest": "^22.4.2",
3334
"jest-flow-transform": "^1.0.1",
3435
"lodash": "^4.17.2"
3536
},
3637
"jest": {
3738
"rootDir": "src",
3839
"setupFiles": [
39-
"<rootDir>/tests/__mocks__/request-animation-frame.js"
40+
"<rootDir>/tests/__mocks__/request-animation-frame.js",
41+
"<rootDir>/tests/setup.js"
4042
],
4143
"testMatch": [
4244
"**/tests/**/*.js"
4345
],
4446
"testPathIgnorePatterns": [
4547
"/node_modules/",
46-
"<rootDir>/tests/__mocks__/"
48+
"<rootDir>/tests/__mocks__/",
49+
"<rootDir>/tests/setup.js"
4750
],
4851
"transformIgnorePatterns": [
4952
"node_modules/(?!devtools-)"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* This Source Code Form is subject to the terms of the Mozilla Public
2+
* License, v. 2.0. If a copy of the MPL was not distributed with this
3+
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4+
5+
// Configure enzyme with React 16 adapter.
6+
const Enzyme = require("enzyme");
7+
const Adapter = require("enzyme-adapter-react-16");
8+
Enzyme.configure({ adapter: new Adapter() });

packages/devtools-components/src/tests/tree.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ describe("Tree", () => {
9898
className: "testClassName"
9999
});
100100

101-
expect(wrapper.hasClass("testClassName")).toBe(true);
102-
expect(wrapper.hasClass("tree")).toBe(true);
101+
expect(wrapper.find(".tree").hasClass("testClassName")).toBe(true);
103102
});
104103

105104
it("renders as expected when passed a style", () => {
@@ -369,9 +368,9 @@ describe("Tree", () => {
369368

370369
getTreeNodes(wrapper).forEach(n => {
371370
if ("ABECDMN".split("").includes(getSanitizedNodeText(n))) {
372-
expect(n.find(".arrow.expanded").exists()).toBe(true);
371+
expect(n.find("i.arrow.expanded").exists()).toBe(true);
373372
} else {
374-
expect(n.find(".arrow").exists()).toBe(false);
373+
expect(n.find("i.arrow").exists()).toBe(false);
375374
}
376375
});
377376
});
@@ -381,7 +380,7 @@ describe("Tree", () => {
381380
expect(formatTree(wrapper)).toMatchSnapshot();
382381

383382
getTreeNodes(wrapper).forEach(n => {
384-
const arrow = n.find(".arrow");
383+
const arrow = n.find("i.arrow");
385384
expect(arrow.exists()).toBe(true);
386385
expect(arrow.hasClass("expanded")).toBe(false);
387386
});
@@ -442,7 +441,7 @@ function formatTree(wrapper) {
442441
.map((node) => {
443442
const level = node.prop("aria-level");
444443
const indentStr = "| ".repeat(level || 0);
445-
const arrow = node.find(".arrow");
444+
const arrow = node.find("i.arrow");
446445
let arrowStr = " ";
447446
if (arrow.exists()) {
448447
arrowStr = arrow.hasClass("expanded") ? "▼ " : "▶︎ ";

0 commit comments

Comments
 (0)