diff --git a/example/setupTest.example.js b/example/setupTest.example.js index 8fc96a7a2..a31024e0a 100644 --- a/example/setupTest.example.js +++ b/example/setupTest.example.js @@ -1,13 +1,9 @@ /* eslint-disable import/no-extraneous-dependencies */ import 'core-js/stable'; import 'regenerator-runtime/runtime'; -import Enzyme from 'enzyme'; -import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; import MutationObserver from '@sheerun/mutationobserver-shim'; import { mergeConfig } from '@edx/frontend-platform'; -Enzyme.configure({ adapter: new Adapter() }); - /* need to mock window for tinymce on import, as it is JSDOM incompatible */ Object.defineProperty(window, 'matchMedia', { diff --git a/jest.config.js b/jest.config.js index 6059ddf5e..20c32cdab 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,9 +8,6 @@ module.exports = createConfig('jest', { '/src/setupTest.js', ], modulePaths: ['/src/'], - snapshotSerializers: [ - 'enzyme-to-json/serializer', - ], moduleNameMapper: { '^lodash-es$': 'lodash', }, diff --git a/package-lock.json b/package-lock.json index eedecadb4..d96c4b8a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,14 +49,12 @@ "@edx/frontend-build": "13.0.1", "@edx/frontend-platform": "5.5.4", "@edx/paragon": "^21.5.6", + "@edx/react-unit-test-utils": "1.7.1", "@edx/reactifex": "^2.1.1", "@testing-library/dom": "^8.13.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^12.1.5", "@testing-library/user-event": "^13.5.0", - "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0", - "enzyme": "3.11.0", - "enzyme-to-json": "^3.6.2", "eslint-import-resolver-alias": "^1.1.2", "eslint-plugin-import": "^2.26.0", "husky": "7.0.4", @@ -2936,6 +2934,325 @@ "node": ">=8" } }, + "node_modules/@edx/react-unit-test-utils": { + "version": "1.7.1", + "resolved": "https://registry.npmjs.org/@edx/react-unit-test-utils/-/react-unit-test-utils-1.7.1.tgz", + "integrity": "sha512-EEMoy0SIZOpJAsrr8BNxW+ZL13UzqCw0z5MFNO1AGgElsUbiXiVY/ReRkstLJjf4CFiXro6mFhtKMFmz1Wg2cQ==", + "dev": true, + "dependencies": { + "@edx/browserslist-config": "^1.1.1", + "@edx/frontend-platform": "4.6.0", + "@edx/paragon": "^20.44.0", + "@reduxjs/toolkit": "^1.5.1", + "@testing-library/dom": "^9.3.0", + "@testing-library/jest-dom": "^5.16.5", + "@testing-library/react": "^12.1.5", + "@testing-library/react-hooks": "^8.0.1", + "classnames": "^2.2.6", + "core-js": "3.6.5", + "lodash": "^4.17.21", + "react-dev-utils": "^12.0.1", + "react-test-renderer": "17.0.2" + }, + "peerDependencies": { + "@edx/frontend-build": ">=8.1.0", + "react": "^16.9.0 || ^17.0.0" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/@edx/frontend-platform": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/@edx/frontend-platform/-/frontend-platform-4.6.0.tgz", + "integrity": "sha512-NZ1I3BgUZl7bqvDwSnnL+LxqZOdOUGZU55KiwvknqiKU8RS5Lx9tc4arp+NcX1u58xy/Xbinv+mriSO6PPxQNQ==", + "dev": true, + "dependencies": { + "@cospired/i18n-iso-languages": "4.1.0", + "@formatjs/intl-pluralrules": "4.3.3", + "@formatjs/intl-relativetimeformat": "10.0.1", + "axios": "0.27.2", + "axios-cache-interceptor": "0.10.7", + "form-urlencoded": "4.1.4", + "glob": "7.2.3", + "history": "4.10.1", + "i18n-iso-countries": "4.3.1", + "jwt-decode": "3.1.2", + "localforage": "1.10.0", + "localforage-memoryStorageDriver": "0.9.2", + "lodash.camelcase": "4.3.0", + "lodash.memoize": "4.1.2", + "lodash.merge": "4.6.2", + "lodash.snakecase": "4.1.1", + "pubsub-js": "1.9.4", + "react-intl": "^5.25.0", + "universal-cookie": "4.0.4" + }, + "bin": { + "intl-imports.js": "i18n/scripts/intl-imports.js", + "transifex-utils.js": "i18n/scripts/transifex-utils.js" + }, + "peerDependencies": { + "@edx/frontend-build": ">= 8.1.0", + "@edx/paragon": ">= 10.0.0 < 21.0.0", + "prop-types": "^15.7.2", + "react": "^16.9.0 || ^17.0.0", + "react-dom": "^16.9.0 || ^17.0.0", + "react-redux": "^7.1.1", + "react-router-dom": "^5.0.1", + "redux": "^4.0.4" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/@edx/paragon": { + "version": "20.46.3", + "resolved": "https://registry.npmjs.org/@edx/paragon/-/paragon-20.46.3.tgz", + "integrity": "sha512-cHxoxoOREVFbBqW9IRAtlIAQo1lcF9JJXkLoEw1Vam6oetKSa5Mc0SL5kykbV+1iRPP7kS8A0Csf5nRr0oolLQ==", + "dev": true, + "dependencies": { + "@fortawesome/fontawesome-svg-core": "^6.1.1", + "@fortawesome/react-fontawesome": "^0.1.18", + "@popperjs/core": "^2.11.4", + "bootstrap": "^4.6.2", + "classnames": "^2.3.1", + "email-prop-type": "^3.0.0", + "file-selector": "^0.6.0", + "font-awesome": "^4.7.0", + "glob": "^8.0.3", + "lodash.uniqby": "^4.7.0", + "mailto-link": "^2.0.0", + "prop-types": "^15.8.1", + "react-bootstrap": "^1.6.5", + "react-colorful": "^5.6.1", + "react-dropzone": "^14.2.1", + "react-focus-on": "^3.5.4", + "react-loading-skeleton": "^3.1.0", + "react-popper": "^2.2.5", + "react-proptype-conditional-require": "^1.0.4", + "react-responsive": "^8.2.0", + "react-table": "^7.7.0", + "react-transition-group": "^4.4.2", + "tabbable": "^5.3.3", + "uncontrollable": "^7.2.1", + "uuid": "^9.0.0" + }, + "peerDependencies": { + "react": "^16.8.6 || ^17.0.0", + "react-dom": "^16.8.6 || ^17.0.0", + "react-intl": "^5.25.1" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/@edx/paragon/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/@testing-library/dom": { + "version": "9.3.3", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-9.3.3.tgz", + "integrity": "sha512-fB0R+fa3AUqbLHWyxXa2kGVtf1Fe1ZZFr0Zp6AIbIAzXb2mKbEXl+PCQNUOaq5lbTab5tfctfXRNsWXxa2f7Aw==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.1.3", + "chalk": "^4.1.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/@edx/react-unit-test-utils/node_modules/core-js": { + "version": "3.6.5", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.6.5.tgz", + "integrity": "sha512-vZVEEwZoIsI+vPEuoF9Iqf5H7/M3eeQqWlQnYa8FSKKePuYTf5MWnxb5SDAzCa60b3JBRS5g9b+Dq7b1y/RCrA==", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", + "dev": true, + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==", + "dev": true, + "peer": true + }, + "node_modules/@edx/react-unit-test-utils/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/path-to-regexp": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", + "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "dev": true, + "peer": true, + "dependencies": { + "isarray": "0.0.1" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/prop-types": { + "version": "15.8.1", + "resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz", + "integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==", + "dev": true, + "dependencies": { + "loose-envify": "^1.4.0", + "object-assign": "^4.1.1", + "react-is": "^16.13.1" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", + "dev": true + }, + "node_modules/@edx/react-unit-test-utils/node_modules/react-router": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.3.4.tgz", + "integrity": "sha512-Ys9K+ppnJah3QuaRiLxk+jDWOR1MekYQrlytiXxC1RyfbdsZkS5pvKAzCCr031xHixZwpnsYNT5xysdFHQaYsA==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.12.13", + "history": "^4.9.0", + "hoist-non-react-statics": "^3.1.0", + "loose-envify": "^1.3.1", + "path-to-regexp": "^1.7.0", + "prop-types": "^15.6.2", + "react-is": "^16.6.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0" + }, + "peerDependencies": { + "react": ">=15" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/react-router-dom": { + "version": "5.3.4", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.3.4.tgz", + "integrity": "sha512-m4EqFMHv/Ih4kpcBCONHbkT68KoAeHN4p3lAGoNryfHi0dMy0kCzEZakiKRsvg5wHZ/JLrLW8o8KomWiz/qbYQ==", + "dev": true, + "peer": true, + "dependencies": { + "@babel/runtime": "^7.12.13", + "history": "^4.9.0", + "loose-envify": "^1.3.1", + "prop-types": "^15.6.2", + "react-router": "5.3.4", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0" + }, + "peerDependencies": { + "react": ">=15" + } + }, + "node_modules/@edx/react-unit-test-utils/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@edx/reactifex": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@edx/reactifex/-/reactifex-2.2.0.tgz", @@ -5277,6 +5594,36 @@ "react-dom": "<18.0.0" } }, + "node_modules/@testing-library/react-hooks": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/@testing-library/react-hooks/-/react-hooks-8.0.1.tgz", + "integrity": "sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5", + "react-error-boundary": "^3.1.0" + }, + "engines": { + "node": ">=12" + }, + "peerDependencies": { + "@types/react": "^16.9.0 || ^17.0.0", + "react": "^16.9.0 || ^17.0.0", + "react-dom": "^16.9.0 || ^17.0.0", + "react-test-renderer": "^16.9.0 || ^17.0.0" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "react-dom": { + "optional": true + }, + "react-test-renderer": { + "optional": true + } + } + }, "node_modules/@testing-library/user-event": { "version": "13.5.0", "resolved": "https://registry.npmjs.org/@testing-library/user-event/-/user-event-13.5.0.tgz", @@ -5391,15 +5738,6 @@ "@types/node": "*" } }, - "node_modules/@types/cheerio": { - "version": "0.22.31", - "resolved": "https://registry.npmjs.org/@types/cheerio/-/cheerio-0.22.31.tgz", - "integrity": "sha512-Kt7Cdjjdi2XWSfrZ53v4Of0wG3ZcmaegFXjMmz9tfNrZSkzzo36G0AL1YqSdcIA78Etjt6E609pt5h1xnQkPUw==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/connect": { "version": "3.4.36", "resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.36.tgz", @@ -5997,46 +6335,6 @@ } } }, - "node_modules/@wojtekmaj/enzyme-adapter-react-17": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/@wojtekmaj/enzyme-adapter-react-17/-/enzyme-adapter-react-17-0.8.0.tgz", - "integrity": "sha512-zeUGfQRziXW7R7skzNuJyi01ZwuKCH8WiBNnTgUJwdS/CURrJwAhWsfW7nG7E30ak8Pu3ZwD9PlK9skBfAoOBw==", - "dev": true, - "dependencies": { - "@wojtekmaj/enzyme-adapter-utils": "^0.2.0", - "enzyme-shallow-equal": "^1.0.0", - "has": "^1.0.0", - "prop-types": "^15.7.0", - "react-is": "^17.0.0", - "react-test-renderer": "^17.0.0" - }, - "funding": { - "url": "https://github.com/wojtekmaj/enzyme-adapter-react-17?sponsor=1" - }, - "peerDependencies": { - "enzyme": "^3.0.0", - "react": "^17.0.0-0", - "react-dom": "^17.0.0-0" - } - }, - "node_modules/@wojtekmaj/enzyme-adapter-utils": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/@wojtekmaj/enzyme-adapter-utils/-/enzyme-adapter-utils-0.2.0.tgz", - "integrity": "sha512-ZvZm9kZxZEKAbw+M1/Q3iDuqQndVoN8uLnxZ8bzxm7KgGTBejrGRoJAp8f1EN8eoO3iAjBNEQnTDW/H4Ekb0FQ==", - "dev": true, - "dependencies": { - "function.prototype.name": "^1.1.0", - "has": "^1.0.0", - "object.fromentries": "^2.0.0", - "prop-types": "^15.7.0" - }, - "funding": { - "url": "https://github.com/wojtekmaj/enzyme-adapter-utils?sponsor=1" - }, - "peerDependencies": { - "react": "^17.0.0-0" - } - }, "node_modules/@xmldom/xmldom": { "version": "0.8.8", "resolved": "https://registry.npmjs.org/@xmldom/xmldom/-/xmldom-0.8.8.tgz", @@ -6398,25 +6696,6 @@ "node": ">=0.10.0" } }, - "node_modules/array.prototype.filter": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/array.prototype.filter/-/array.prototype.filter-1.0.2.tgz", - "integrity": "sha512-us+UrmGOilqttSOgoWZTpOvHu68vZT2YCjc/H4vhu56vzZpaDFBhB+Se2UwqWzMKbDv7Myq5M5pcZLAtUvTQdQ==", - "dev": true, - "dependencies": { - "call-bind": "^1.0.2", - "define-properties": "^1.1.4", - "es-abstract": "^1.20.4", - "es-array-method-boxes-properly": "^1.0.0", - "is-string": "^1.0.7" - }, - "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/array.prototype.flat": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz", @@ -7547,44 +7826,6 @@ "integrity": "sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==", "dev": true }, - "node_modules/cheerio": { - "version": "1.0.0-rc.12", - "resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz", - "integrity": "sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q==", - "dev": true, - "dependencies": { - "cheerio-select": "^2.1.0", - "dom-serializer": "^2.0.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "htmlparser2": "^8.0.1", - "parse5": "^7.0.0", - "parse5-htmlparser2-tree-adapter": "^7.0.0" - }, - "engines": { - "node": ">= 6" - }, - "funding": { - "url": "https://github.com/cheeriojs/cheerio?sponsor=1" - } - }, - "node_modules/cheerio-select": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/cheerio-select/-/cheerio-select-2.1.0.tgz", - "integrity": "sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==", - "dev": true, - "dependencies": { - "boolbase": "^1.0.0", - "css-select": "^5.1.0", - "css-what": "^6.1.0", - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1" - }, - "funding": { - "url": "https://github.com/sponsors/fb55" - } - }, "node_modules/child_process": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/child_process/-/child_process-1.0.2.tgz", @@ -8803,12 +9044,6 @@ "node": ">=8" } }, - "node_modules/discontinuous-range": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/discontinuous-range/-/discontinuous-range-1.0.0.tgz", - "integrity": "sha512-c68LpLbO+7kP/b1Hr1qs8/BJ09F5khZGTxqxZuhzxpmwJKOgRFHJWIb9/KmqnqHhLdO55aOxFH/EGBvUQbL/RQ==", - "dev": true - }, "node_modules/dns-equal": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/dns-equal/-/dns-equal-1.0.0.tgz", @@ -9080,75 +9315,6 @@ "node": ">=4" } }, - "node_modules/enzyme": { - "version": "3.11.0", - "resolved": "https://registry.npmjs.org/enzyme/-/enzyme-3.11.0.tgz", - "integrity": "sha512-Dw8/Gs4vRjxY6/6i9wU0V+utmQO9kvh9XLnz3LIudviOnVYDEe2ec+0k+NQoMamn1VrjKgCUOWj5jG/5M5M0Qw==", - "dev": true, - "dependencies": { - "array.prototype.flat": "^1.2.3", - "cheerio": "^1.0.0-rc.3", - "enzyme-shallow-equal": "^1.0.1", - "function.prototype.name": "^1.1.2", - "has": "^1.0.3", - "html-element-map": "^1.2.0", - "is-boolean-object": "^1.0.1", - "is-callable": "^1.1.5", - "is-number-object": "^1.0.4", - "is-regex": "^1.0.5", - "is-string": "^1.0.5", - "is-subset": "^0.1.1", - "lodash.escape": "^4.0.1", - "lodash.isequal": "^4.5.0", - "object-inspect": "^1.7.0", - "object-is": "^1.0.2", - "object.assign": "^4.1.0", - "object.entries": "^1.1.1", - "object.values": "^1.1.1", - "raf": "^3.4.1", - "rst-selector-parser": "^2.2.3", - "string.prototype.trim": "^1.2.1" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/enzyme-shallow-equal": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/enzyme-shallow-equal/-/enzyme-shallow-equal-1.0.5.tgz", - "integrity": "sha512-i6cwm7hN630JXenxxJFBKzgLC3hMTafFQXflvzHgPmDhOBhxUWDe8AeRv1qp2/uWJ2Y8z5yLWMzmAfkTOiOCZg==", - "dev": true, - "dependencies": { - "has": "^1.0.3", - "object-is": "^1.1.5" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/enzyme-to-json": { - "version": "3.6.2", - "resolved": "https://registry.npmjs.org/enzyme-to-json/-/enzyme-to-json-3.6.2.tgz", - "integrity": "sha512-Ynm6Z6R6iwQ0g2g1YToz6DWhxVnt8Dy1ijR2zynRKxTyBGA8rCDXU3rs2Qc4OKvUvc2Qoe1bcFK6bnPs20TrTg==", - "dev": true, - "dependencies": { - "@types/cheerio": "^0.22.22", - "lodash": "^4.17.21", - "react-is": "^16.12.0" - }, - "engines": { - "node": ">=6.0.0" - }, - "peerDependencies": { - "enzyme": "^3.4.0" - } - }, - "node_modules/enzyme-to-json/node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==", - "dev": true - }, "node_modules/error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -9212,12 +9378,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/es-array-method-boxes-properly": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz", - "integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA==", - "dev": true - }, "node_modules/es-get-iterator": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz", @@ -13257,19 +13417,6 @@ "wbuf": "^1.1.0" } }, - "node_modules/html-element-map": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/html-element-map/-/html-element-map-1.3.1.tgz", - "integrity": "sha512-6XMlxrAFX4UEEGxctfFnmrFaaZFNf9i5fNuV5wZ3WWQ4FVaNP1aX1LkX9j2mfEx1NpjeE/rL3nmgEn23GdFmrg==", - "dev": true, - "dependencies": { - "array.prototype.filter": "^1.0.0", - "call-bind": "^1.0.2" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/html-encoding-sniffer": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", @@ -13352,25 +13499,6 @@ "webpack": "^5.20.0" } }, - "node_modules/htmlparser2": { - "version": "8.0.2", - "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-8.0.2.tgz", - "integrity": "sha512-GYdjWKDkbRLkZ5geuHs5NY1puJ+PXwP7+fHPRz06Eirsb9ugf6d8kkXav6ADhcODhFFPMIXyxkxSuMf3D6NCFA==", - "dev": true, - "funding": [ - "https://github.com/fb55/htmlparser2?sponsor=1", - { - "type": "github", - "url": "https://github.com/sponsors/fb55" - } - ], - "dependencies": { - "domelementtype": "^2.3.0", - "domhandler": "^5.0.3", - "domutils": "^3.0.1", - "entities": "^4.4.0" - } - }, "node_modules/http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", @@ -14350,12 +14478,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-subset": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", - "integrity": "sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==", - "dev": true - }, "node_modules/is-symbol": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", @@ -17215,24 +17337,12 @@ "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", "integrity": "sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==" }, - "node_modules/lodash.flattendeep": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", - "integrity": "sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==", - "dev": true - }, "node_modules/lodash.invokemap": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.invokemap/-/lodash.invokemap-4.6.0.tgz", "integrity": "sha512-CfkycNtMqgUlfjfdh2BhKO/ZXrP8ePOX5lEU/g0R3ItJcnuxWDwokMGKx1hWcfOikmyOVx6X9IwWnDGlgKl61w==", "dev": true }, - "node_modules/lodash.isequal": { - "version": "4.5.0", - "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz", - "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==", - "dev": true - }, "node_modules/lodash.isplainobject": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", @@ -17687,12 +17797,6 @@ "moment": "^2.4.0" } }, - "node_modules/moo": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/moo/-/moo-0.5.2.tgz", - "integrity": "sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==", - "dev": true - }, "node_modules/moo-color": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/moo-color/-/moo-color-1.0.3.tgz", @@ -17817,34 +17921,6 @@ "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==" }, - "node_modules/nearley": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/nearley/-/nearley-2.20.1.tgz", - "integrity": "sha512-+Mc8UaAebFzgV+KpI5n7DasuuQCHA89dmwm7JXw3TV43ukfNQ9DnBH3Mdb2g/I4Fdxc26pwimBWvjIw0UAILSQ==", - "dev": true, - "dependencies": { - "commander": "^2.19.0", - "moo": "^0.5.0", - "railroad-diagrams": "^1.0.0", - "randexp": "0.4.6" - }, - "bin": { - "nearley-railroad": "bin/nearley-railroad.js", - "nearley-test": "bin/nearley-test.js", - "nearley-unparse": "bin/nearley-unparse.js", - "nearleyc": "bin/nearleyc.js" - }, - "funding": { - "type": "individual", - "url": "https://nearley.js.org/#give-to-nearley" - } - }, - "node_modules/nearley/node_modules/commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true - }, "node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -18579,31 +18655,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/parse5": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-7.1.2.tgz", - "integrity": "sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==", - "dev": true, - "dependencies": { - "entities": "^4.4.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, - "node_modules/parse5-htmlparser2-tree-adapter": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz", - "integrity": "sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g==", - "dev": true, - "dependencies": { - "domhandler": "^5.0.2", - "parse5": "^7.0.0" - }, - "funding": { - "url": "https://github.com/inikulin/parse5?sponsor=1" - } - }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -18676,12 +18727,6 @@ "node": ">=8" } }, - "node_modules/performance-now": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", - "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==", - "dev": true - }, "node_modules/picocolors": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", @@ -19793,34 +19838,6 @@ "resolved": "https://registry.npmjs.org/queue-tick/-/queue-tick-1.0.1.tgz", "integrity": "sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==" }, - "node_modules/raf": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/raf/-/raf-3.4.1.tgz", - "integrity": "sha512-Sq4CW4QhwOHE8ucn6J34MqtZCeWFP2aQSmrlroYgqAV1PjStIhJXxYuTgUIfkEk7zTLjmIjLmU5q+fbD1NnOJA==", - "dev": true, - "dependencies": { - "performance-now": "^2.1.0" - } - }, - "node_modules/railroad-diagrams": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", - "integrity": "sha512-cz93DjNeLY0idrCNOH6PviZGRN9GJhsdm9hpn1YCS879fj4W+x5IFJhhkRZcwVgMmFF7R82UA/7Oh+R8lLZg6A==", - "dev": true - }, - "node_modules/randexp": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/randexp/-/randexp-0.4.6.tgz", - "integrity": "sha512-80WNmd9DA0tmZrw9qQa62GPPWfuXJknrmVmLcxvq4uZBdYqb1wYoKTmnlGUchvVWe0XiLupYkBoXVOxz3C8DYQ==", - "dev": true, - "dependencies": { - "discontinuous-range": "1.0.0", - "ret": "~0.1.10" - }, - "engines": { - "node": ">=0.12" - } - }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -20143,6 +20160,22 @@ "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" }, + "node_modules/react-error-boundary": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/react-error-boundary/-/react-error-boundary-3.1.4.tgz", + "integrity": "sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.12.5" + }, + "engines": { + "node": ">=10", + "npm": ">=6" + }, + "peerDependencies": { + "react": ">=16.13.1" + } + }, "node_modules/react-error-overlay": { "version": "6.0.11", "resolved": "https://registry.npmjs.org/react-error-overlay/-/react-error-overlay-6.0.11.tgz", @@ -21096,16 +21129,6 @@ "rimraf": "bin.js" } }, - "node_modules/rst-selector-parser": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/rst-selector-parser/-/rst-selector-parser-2.2.3.tgz", - "integrity": "sha512-nDG1rZeP6oFTLN6yNDV/uiAvs1+FS/KlrEwh7+y7dpuApDBy6bI2HTBcc0/V8lv9OTqfyD34eF7au2pm8aBbhA==", - "dev": true, - "dependencies": { - "lodash.flattendeep": "^4.4.0", - "nearley": "^2.7.10" - } - }, "node_modules/rsvp": { "version": "4.8.5", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz", diff --git a/package.json b/package.json index c55eeacc9..97e04c0d3 100644 --- a/package.json +++ b/package.json @@ -42,14 +42,12 @@ "@edx/frontend-build": "13.0.1", "@edx/frontend-platform": "5.5.4", "@edx/paragon": "^21.5.6", + "@edx/react-unit-test-utils": "1.7.1", "@edx/reactifex": "^2.1.1", "@testing-library/dom": "^8.13.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^12.1.5", "@testing-library/user-event": "^13.5.0", - "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0", - "enzyme": "3.11.0", - "enzyme-to-json": "^3.6.2", "eslint-import-resolver-alias": "^1.1.2", "eslint-plugin-import": "^2.26.0", "husky": "7.0.4", diff --git a/src/editors/Editor.test.jsx b/src/editors/Editor.test.jsx index 54d68a062..d2f09629b 100644 --- a/src/editors/Editor.test.jsx +++ b/src/editors/Editor.test.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { useDispatch } from 'react-redux'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { Editor } from './Editor'; import supportedEditors from './supportedEditors'; import * as hooks from './hooks'; @@ -32,14 +32,14 @@ let el; describe('Editor', () => { describe('render', () => { test('snapshot: renders correct editor given blockType (html -> TextEditor)', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('presents error message if no relevant editor found and ref ready', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test.each(Object.values(blockTypes))('renders %p editor when ref is ready', (blockType) => { el = shallow(); - expect(el.children().children().at(0).is(supportedEditors[blockType])).toBe(true); + expect(el.shallowWrapper.props.children.props.children.type).toBe(supportedEditors[blockType]); }); }); describe('behavior', () => { diff --git a/src/editors/EditorPage.test.jsx b/src/editors/EditorPage.test.jsx index 8c9348cde..24dfffe29 100644 --- a/src/editors/EditorPage.test.jsx +++ b/src/editors/EditorPage.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import EditorPage from './EditorPage'; const props = { @@ -23,10 +23,10 @@ jest.mock('./Editor', () => 'Editor'); describe('Editor Page', () => { describe('snapshots', () => { test('rendering correctly with expected Input', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('props besides blockType default to null', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/VideoSelector.test.jsx b/src/editors/VideoSelector.test.jsx index 69c3b6034..aa55253f8 100644 --- a/src/editors/VideoSelector.test.jsx +++ b/src/editors/VideoSelector.test.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { useDispatch } from 'react-redux'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import * as hooks from './hooks'; import VideoSelector from './VideoSelector'; @@ -25,7 +25,7 @@ const initData = { describe('Video Selector', () => { describe('render', () => { test('rendering correctly with expected Input', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); describe('behavior', () => { diff --git a/src/editors/VideoSelectorPage.test.jsx b/src/editors/VideoSelectorPage.test.jsx index 7679b25e7..5f55f7c33 100644 --- a/src/editors/VideoSelectorPage.test.jsx +++ b/src/editors/VideoSelectorPage.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import VideoSelectorPage from './VideoSelectorPage'; const props = { @@ -22,10 +22,10 @@ jest.mock('./VideoSelector', () => 'VideoSelector'); describe('Video Selector Page', () => { describe('snapshots', () => { test('rendering correctly with expected Input', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('rendering with props to null', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/EditorContainer/components/EditorFooter/index.test.jsx b/src/editors/containers/EditorContainer/components/EditorFooter/index.test.jsx index 9aac7b638..aabc48134 100644 --- a/src/editors/containers/EditorContainer/components/EditorFooter/index.test.jsx +++ b/src/editors/containers/EditorContainer/components/EditorFooter/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { useSelector } from 'react-redux'; import { formatMessage } from '../../../../../testUtils'; @@ -23,22 +23,22 @@ describe('EditorFooter', () => { }; describe('render', () => { test('snapshot: default args (disableSave: false, saveFailed: false)', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: save disabled. Show button spinner', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: save failed. Show error message', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: show feedback link', () => { useSelector.mockReturnValueOnce('problem'); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: dont show feedback link', () => { useSelector.mockReturnValueOnce('not a Problem'); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/EditorContainer/components/TitleHeader/EditConfirmationButtons.test.jsx b/src/editors/containers/EditorContainer/components/TitleHeader/EditConfirmationButtons.test.jsx index e342cf054..65619c46c 100644 --- a/src/editors/containers/EditorContainer/components/TitleHeader/EditConfirmationButtons.test.jsx +++ b/src/editors/containers/EditorContainer/components/TitleHeader/EditConfirmationButtons.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../testUtils'; import * as module from './EditConfirmationButtons'; @@ -11,7 +11,7 @@ describe('EditConfirmationButtons', () => { }; describe('snapshot', () => { test('snapshot', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/EditorContainer/components/TitleHeader/EditableHeader.test.jsx b/src/editors/containers/EditorContainer/components/TitleHeader/EditableHeader.test.jsx index c4a07addc..05012681c 100644 --- a/src/editors/containers/EditorContainer/components/TitleHeader/EditableHeader.test.jsx +++ b/src/editors/containers/EditorContainer/components/TitleHeader/EditableHeader.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { Form } from '@edx/paragon'; import * as module from './EditableHeader'; import EditConfirmationButtons from './EditConfirmationButtons'; @@ -20,11 +20,11 @@ describe('EditableHeader', () => { describe('snapshot', () => { test('snapshot', () => { - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); }); test('displays Edit Icon', () => { - const formControl = el.find(Form.Control); - expect(formControl.props().trailingElement).toMatchObject( + const formControl = el.instance.findByType(Form.Control)[0]; + expect(formControl.props.trailingElement).toMatchObject( , ); }); diff --git a/src/editors/containers/EditorContainer/components/TitleHeader/__snapshots__/index.test.jsx.snap b/src/editors/containers/EditorContainer/components/TitleHeader/__snapshots__/index.test.jsx.snap index 279d85a82..3b0f744e2 100644 --- a/src/editors/containers/EditorContainer/components/TitleHeader/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/EditorContainer/components/TitleHeader/__snapshots__/index.test.jsx.snap @@ -15,7 +15,9 @@ exports[`TitleHeader snapshots initialized 1`] = ` className="d-flex flex-row align-items-center mt-1" > - + Object { + "useSelector": [Function], + } ({ localTitleHooks: jest.fn(), })); +jest.mock('@edx/paragon', () => ({ + ...jest.requireActual('@edx/paragon'), + Truncate: ({ children }) =>
{children}
, // eslint-disable-line react/prop-types + IconButton: 'IconButton', + Icon: 'Icon', +})); +jest.mock('./EditableHeader'); describe('TitleHeader', () => { const props = { @@ -40,15 +47,15 @@ describe('TitleHeader', () => { describe('snapshots', () => { test('not initialized', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('initialized', () => { localTitleHooks.mockReturnValue(localTitleHooksProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().shallowWrapper).toMatchSnapshot(); }); test('editing', () => { localTitleHooks.mockReturnValue({ ...localTitleHooksProps, isEditing: true }); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/EditorContainer/index.test.jsx b/src/editors/containers/EditorContainer/index.test.jsx index 2ca5f70d1..c0068955a 100644 --- a/src/editors/containers/EditorContainer/index.test.jsx +++ b/src/editors/containers/EditorContainer/index.test.jsx @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { useDispatch } from 'react-redux'; import { EditorContainer } from '.'; @@ -35,12 +35,12 @@ describe('EditorContainer component', () => { test('snapshot: not initialized. disable save and pass to header', () => { hooks.isInitialized.mockReturnValueOnce(false); expect( - shallow({testContent}), + shallow({testContent}).snapshot, ).toMatchSnapshot(); }); test('snapshot: initialized. enable save and pass to header', () => { expect( - shallow({testContent}), + shallow({testContent}).snapshot, ).toMatchSnapshot(); }); describe('behavior inspection', () => { @@ -54,13 +54,13 @@ describe('EditorContainer component', () => { validateEntry: props.validateEntry, returnFunction: props.returnFunction, }); - expect(el.children().at(3) - .props().onSave).toEqual(expected); + expect(el.shallowWrapper.props.children[3] + .props.onSave).toEqual(expected); }); test('behavior is linked to clearSaveError', () => { const expected = hooks.clearSaveError({ dispatch: useDispatch() }); - expect(el.children().at(3) - .props().clearSaveFailed).toEqual(expected); + expect(el.shallowWrapper.props.children[3] + .props.clearSaveFailed).toEqual(expected); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswerOption.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswerOption.test.jsx index 69a4cba2f..862b3b214 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswerOption.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswerOption.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../testUtils'; import { selectors } from '../../../../../data/redux'; import { AnswerOption, mapStateToProps } from './AnswerOption'; @@ -51,16 +51,16 @@ describe('AnswerOption', () => { }; describe('render', () => { test('snapshot: renders correct option with feedback', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders correct option with selected unselected feedback', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders correct option with numeric input problem', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders correct option with numeric input problem and answer range', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswersContainer.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswersContainer.test.jsx index 475efac0d..1445c0cdd 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswersContainer.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/AnswersContainer.test.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { act, render, waitFor } from '@testing-library/react'; import { actions, selectors } from '../../../../../data/redux'; @@ -44,7 +44,7 @@ describe('AnswersContainer', () => { describe('render', () => { test('snapshot: renders correct default', () => { act(() => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); test('snapshot: renders correctly with answers', () => { @@ -54,7 +54,7 @@ describe('AnswersContainer', () => { {...props} answers={[{ id: 'a', title: 'sOMetITlE', correct: true }, { id: 'b', title: 'sOMetITlE', correct: true }]} />, - )).toMatchSnapshot(); + ).snapshot).toMatchSnapshot(); }); }); test('snapshot: numeric problems: answer range/answer select button: empty', () => { @@ -70,7 +70,7 @@ describe('AnswersContainer', () => { , - )).toMatchSnapshot(); + ).snapshot).toMatchSnapshot(); }); }); test('snapshot: numeric problems: answer range/answer select button: Range disables the additon of more adds', () => { @@ -93,7 +93,7 @@ describe('AnswersContainer', () => { , - )).toMatchSnapshot(); + ).snapshot).toMatchSnapshot(); }); }); test('snapshot: numeric problems: answer range/answer select button: multiple answers disables range.', () => { @@ -125,7 +125,7 @@ describe('AnswersContainer', () => { , - )).toMatchSnapshot(); + ).snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Checker/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Checker/index.test.jsx index 0ecb229be..46653ced1 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Checker/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Checker/index.test.jsx @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import Checker from '.'; const props = { @@ -13,14 +13,14 @@ const props = { }; describe('Checker component', () => { test('with single answer', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('with multiple answers', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('with disabled', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackBox.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackBox.test.jsx index 62c428ad8..885cb7a6d 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackBox.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackBox.test.jsx @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { FeedbackBox } from './FeedbackBox'; const answerWithFeedback = { @@ -17,12 +17,12 @@ const props = { describe('FeedbackBox component', () => { test('renders as expected with default props', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('renders as expected with a numeric input problem', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('renders as expected with a multi select problem', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackControl.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackControl.test.jsx index 93d6499d4..13a850af0 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackControl.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/AnswerWidget/components/Feedback/FeedbackControl.test.jsx @@ -1,4 +1,4 @@ -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import FeedbackControl from './FeedbackControl'; const answerWithFeedback = { @@ -21,6 +21,6 @@ const props = { describe('FeedbackControl component', () => { test('renders', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/ExplanationWidget/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/ExplanationWidget/index.test.jsx index aaca85768..7eedd86d5 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/ExplanationWidget/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/ExplanationWidget/index.test.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../testUtils'; import { selectors } from '../../../../../data/redux'; import { ExplanationWidget, mapStateToProps } from '.'; @@ -35,7 +35,7 @@ describe('SolutionWidget', () => { }; describe('render', () => { test('snapshot: renders correct default', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); describe('mapStateToProps', () => { diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/index.test.jsx index 7f76acd6a..5e01ae0b6 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/QuestionWidget/index.test.jsx @@ -1,6 +1,6 @@ /* eslint-disable react/prop-types */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../testUtils'; import { selectors } from '../../../../../data/redux'; import { QuestionWidget, mapStateToProps } from '.'; @@ -47,7 +47,7 @@ describe('QuestionWidget', () => { }; describe('render', () => { test('snapshot: renders correct default', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); describe('mapStateToProps', () => { diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/CardSection.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/CardSection.test.jsx index 5d3dd8a37..2c5bc6960 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/CardSection.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/CardSection.test.jsx @@ -1,12 +1,14 @@ -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import CardSection from './CardSection'; describe('CardSection', () => { test('open', () => { - expect(shallow(

Section Text

)).toMatchSnapshot(); + expect(shallow(

Section Text

).snapshot).toMatchSnapshot(); }); test('closed', () => { - expect(shallow(

Section Text

)).toMatchSnapshot(); + expect( + shallow(

Section Text

).snapshot, + ).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/SettingsOption.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/SettingsOption.test.jsx index dd53fd12d..e7c3074e7 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/SettingsOption.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/SettingsOption.test.jsx @@ -1,12 +1,12 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import SettingsOption from './SettingsOption'; describe('SettingsOption', () => { describe('default with children', () => { const children = (

My test content

); test('snapshot: renders correct', () => { - expect(shallow({children})).toMatchSnapshot(); + expect(shallow({children}).snapshot).toMatchSnapshot(); }); }); describe('with additional sections', () => { @@ -17,7 +17,7 @@ describe('SettingsOption', () => { {children} , - )).toMatchSnapshot(); + ).snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/CardSection.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/CardSection.test.jsx.snap index 706a694c3..f5ba5df9f 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/CardSection.test.jsx.snap +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/CardSection.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`CardSection closed 1`] = `""`; +exports[`CardSection closed 1`] = `null`; exports[`CardSection open 1`] = ` - - + + + + + + `; diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap index 52a608aec..2042e3f43 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/__snapshots__/index.test.jsx.snap @@ -25,6 +25,7 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget for Advanced problemType="stringresponse" /> +
+
+
{ setResetTrue: jest.fn().mockName('showAdvancedSettingsCards.setResetTrue'), }; showAdvancedSettingsCards.mockReturnValue(showAdvancedSettingsCardsProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders Settings widget page advanced settings visible', () => { const showAdvancedSettingsCardsProps = { @@ -58,7 +58,7 @@ describe('SettingsWidget', () => { setResetTrue: jest.fn().mockName('showAdvancedSettingsCards.setResetTrue'), }; showAdvancedSettingsCards.mockReturnValue(showAdvancedSettingsCardsProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders Settings widget for Advanced Problem with correct widgets', () => { const showAdvancedSettingsCardsProps = { @@ -66,7 +66,7 @@ describe('SettingsWidget', () => { setResetTrue: jest.fn().mockName('showAdvancedSettingsCards.setResetTrue'), }; showAdvancedSettingsCards.mockReturnValue(showAdvancedSettingsCardsProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GeneralFeedback/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GeneralFeedback/index.test.jsx index e31ffc065..af5befed9 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GeneralFeedback/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GeneralFeedback/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../../testUtils'; import { GeneralFeedbackCard } from './index'; import { generalFeedbackHooks } from './hooks'; @@ -31,7 +31,7 @@ describe('RandomizationCard', () => { describe('snapshot', () => { test('snapshot: renders general feedback setting card', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/GroupFeedbackRow.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/GroupFeedbackRow.test.jsx index 64c801fea..06cb5f568 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/GroupFeedbackRow.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/GroupFeedbackRow.test.jsx @@ -1,8 +1,25 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../../testUtils'; import { GroupFeedbackRow } from './GroupFeedbackRow'; +jest.mock('@edx/paragon', () => ({ + ...jest.requireActual('@edx/paragon'), + Row: 'Row', + IconButton: 'IconButton', + Icon: 'Icon', + Form: { + CheckboxSet: 'Form.CheckboxSet', + Checkbox: 'Form.CheckboxSet', + Control: 'Form.Control', + }, + ActionRow: 'ActionRow', +})); +jest.mock('@edx/paragon/icons', () => ({ + ...jest.requireActual('@edx/paragon/icons'), + DeleteOutline: 'DeleteOutline', +})); + describe('GroupFeedbackRow', () => { const props = { value: { answers: ['A', 'C'], feedback: 'sOmE FeEDBACK' }, @@ -15,7 +32,7 @@ describe('GroupFeedbackRow', () => { describe('snapshot', () => { test('snapshot: renders hints row', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/__snapshots__/GroupFeedbackRow.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/__snapshots__/GroupFeedbackRow.test.jsx.snap index d305c649c..584d055c4 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/__snapshots__/GroupFeedbackRow.test.jsx.snap +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/__snapshots__/GroupFeedbackRow.test.jsx.snap @@ -18,11 +18,12 @@ exports[`GroupFeedbackRow snapshot snapshot: renders hints row 1`] = ` alt="Delete answer" iconAs="Icon" onClick={[MockFunction handleDelete]} + src="DeleteOutline" variant="primary" />
- - - - + - - + - - + - + - + `; diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/index.test.jsx index 118529d23..b3c7c1d67 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/GroupFeedback/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../../testUtils'; import { GroupFeedbackCard } from './index'; import { groupFeedbackRowHooks, groupFeedbackCardHooks } from './hooks'; @@ -52,7 +52,7 @@ describe('HintsCard', () => { }; groupFeedbackCardHooks.mockReturnValue(groupFeedbacksCardHooksProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders groupFeedbacks setting card one groupFeedback', () => { const groupFeedbacksCardHooksProps = { @@ -64,7 +64,7 @@ describe('HintsCard', () => { }; groupFeedbackCardHooks.mockReturnValue(groupFeedbacksCardHooksProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders groupFeedbacks setting card multiple groupFeedbacks', () => { const groupFeedbacksCardHooksProps = { @@ -76,7 +76,7 @@ describe('HintsCard', () => { }; groupFeedbackCardHooks.mockReturnValue(groupFeedbacksCardHooksProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/HintRow.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/HintRow.test.jsx index 3f3f80f7c..e0d22b587 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/HintRow.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/HintRow.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { HintRow } from './HintRow'; @@ -14,7 +14,7 @@ describe('HintRow', () => { describe('snapshot', () => { test('snapshot: renders hints row', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/HintsCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/HintsCard.test.jsx index ee8001f2c..e1c3e8998 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/HintsCard.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/HintsCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { HintsCard } from './HintsCard'; import { hintsCardHooks, hintsRowHooks } from '../hooks'; @@ -49,7 +49,7 @@ describe('HintsCard', () => { }; hintsCardHooks.mockReturnValue(hintsCardHooksProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders hints setting card one hint', () => { const hintsCardHooksProps = { @@ -61,7 +61,7 @@ describe('HintsCard', () => { }; hintsCardHooks.mockReturnValue(hintsCardHooksProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders hints setting card multiple hints', () => { const hintsCardHooksProps = { @@ -73,7 +73,7 @@ describe('HintsCard', () => { }; hintsCardHooks.mockReturnValue(hintsCardHooksProps); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.jsx index c47799848..8dac761f5 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/Randomization/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../../testUtils'; import { RandomizationCard } from './index'; import { useRandomizationSettingStatus } from './hooks'; @@ -34,13 +34,15 @@ describe('RandomizationCard', () => { describe('snapshot', () => { test('snapshot: renders randomization setting card with randomization defined', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders randomization setting card with default randomization', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders randomization setting card with randomization null', () => { - expect(shallow()).toMatchSnapshot(); + expect( + shallow().snapshot, + ).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ResetCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ResetCard.test.jsx index 33adae278..5802d6d11 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ResetCard.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ResetCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { ResetCard } from './ResetCard'; import { resetCardHooks } from '../hooks'; @@ -44,10 +44,10 @@ describe('ResetCard', () => { describe('snapshot', () => { test('snapshot: renders reset true setting card', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders reset true setting card', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.test.jsx index 19392d810..e95fcbce7 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { scoringCardHooks } from '../hooks'; import { ScoringCard } from './ScoringCard'; @@ -43,7 +43,7 @@ describe('ScoringCard', () => { describe('snapshot', () => { test('snapshot: scoring setting card', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: scoring setting card zero zero weight', () => { expect(shallow( { ...scoring, weight: 0, }} - />)).toMatchSnapshot(); + />).snapshot).toMatchSnapshot(); }); test('snapshot: scoring setting card max attempts', () => { expect(shallow( { number: 0, }, }} - />)).toMatchSnapshot(); + />).snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.test.jsx index 214f7001c..ae1c850e1 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ShowAnswerCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { selectors } from '../../../../../../data/redux'; import { ShowAnswerCard, mapStateToProps, mapDispatchToProps } from './ShowAnswerCard'; @@ -55,7 +55,7 @@ describe('ShowAnswerCard', () => { describe('snapshot', () => { test('snapshot: show answer setting card', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); describe('mapStateToProps', () => { diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/SwitchToAdvancedEditorCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/SwitchToAdvancedEditorCard.test.jsx index 9a91044f3..9f16c8a8d 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/SwitchToAdvancedEditorCard.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/SwitchToAdvancedEditorCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { SwitchToAdvancedEditorCard, mapDispatchToProps } from './SwitchToAdvancedEditorCard'; import { thunkActions } from '../../../../../../data/redux'; @@ -7,12 +7,12 @@ describe('SwitchToAdvancedEditorCard snapshot', () => { const mockSwitchToAdvancedEditor = jest.fn().mockName('switchToAdvancedEditor'); test('snapshot: SwitchToAdvancedEditorCard', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshot: SwitchToAdvancedEditorCard returns null', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TimerCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TimerCard.test.jsx index f60b27499..46de822d5 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TimerCard.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TimerCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { TimerCard } from './TimerCard'; import { timerCardHooks } from '../hooks'; @@ -30,7 +30,7 @@ describe('TimerCard', () => { describe('snapshot', () => { test('snapshot: renders reset true setting card', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TypeCard.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TypeCard.test.jsx index d22ce280d..f64fa1b30 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TypeCard.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TypeCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { TypeCard } from './TypeCard'; import { ProblemTypeKeys } from '../../../../../../data/constants/problem'; @@ -19,7 +19,7 @@ describe('TypeCard', () => { describe('snapshot', () => { test('snapshot: renders type setting card', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TypeRow.test.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TypeRow.test.jsx index 495231ce0..a34c14df0 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TypeRow.test.jsx +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/TypeRow.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { TypeRow } from './TypeRow'; import { typeRowHooks } from '../hooks'; @@ -47,13 +47,13 @@ describe('TypeRow', () => { describe('snapshot', () => { test('snapshot: renders type row setting card', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders type row setting card not selected', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: renders type row setting card last row', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ShowAnswerCard.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ShowAnswerCard.test.jsx.snap index adef7aeac..d175810a6 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ShowAnswerCard.test.jsx.snap +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ShowAnswerCard.test.jsx.snap @@ -8,112 +8,114 @@ exports[`ShowAnswerCard snapshot snapshot: show answer setting card 1`] = ` summary="After Some Number of Attempts" title="Show answer" > -
- - - -
-
- +
- - -
- - + + +
+
- - - - - - - - -
+ + - After Some Number of Attempts - - - - - - + + + + + + + + + + + + + + +
`; diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/SwitchToAdvancedEditorCard.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/SwitchToAdvancedEditorCard.test.jsx.snap index 124838e2d..499684524 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/SwitchToAdvancedEditorCard.test.jsx.snap +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/SwitchToAdvancedEditorCard.test.jsx.snap @@ -56,4 +56,4 @@ exports[`SwitchToAdvancedEditorCard snapshot snapshot: SwitchToAdvancedEditorCar `; -exports[`SwitchToAdvancedEditorCard snapshot snapshot: SwitchToAdvancedEditorCard returns null 1`] = `""`; +exports[`SwitchToAdvancedEditorCard snapshot snapshot: SwitchToAdvancedEditorCard returns null 1`] = `null`; diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/__snapshots__/index.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/__snapshots__/index.test.jsx.snap index c5759ebc7..5dd277355 100644 --- a/src/editors/containers/ProblemEditor/components/EditProblemView/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/ProblemEditor/components/EditProblemView/__snapshots__/index.test.jsx.snap @@ -5,7 +5,7 @@ exports[`EditorProblemView component renders raw editor 1`] = ` getContent={[Function]} returnFunction={null} > - + +
`; @@ -87,26 +91,28 @@ exports[`LicenseWidget snapshots snapshots: renders as expected with isLibrary t - - - - } - /> + + + + + } + /> + `; @@ -135,26 +141,28 @@ exports[`LicenseWidget snapshots snapshots: renders as expected with licenseType - - - - } - /> + + + + + } + /> + `; diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/index.test.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/index.test.jsx index 41fdeb9ef..823e65166 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/index.test.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { actions, selectors } from '../../../../../../data/redux'; @@ -60,17 +60,17 @@ describe('LicenseWidget', () => { // }); test('snapshots: renders as expected with default props', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with isLibrary true', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with licenseType defined', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/SocialShareWidget/__snapshots__/index.test.jsx.snap b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/SocialShareWidget/__snapshots__/index.test.jsx.snap index 701f3f788..b654d77b0 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/SocialShareWidget/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/SocialShareWidget/__snapshots__/index.test.jsx.snap @@ -1,10 +1,10 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`SocialShareWidget rendered with videoSharingEnabled false with default props should return null 1`] = `""`; +exports[`SocialShareWidget rendered with videoSharingEnabled false with default props should return null 1`] = `null`; -exports[`SocialShareWidget rendered with videoSharingEnabled false with videoSharingEnabledForAll false and isLibrary true should return null 1`] = `""`; +exports[`SocialShareWidget rendered with videoSharingEnabled false with videoSharingEnabledForAll false and isLibrary true should return null 1`] = `null`; -exports[`SocialShareWidget rendered with videoSharingEnabled false with videoSharingEnabledForCourse and isLibrary false and videoSharingEnabledForAll true should return null 1`] = `""`; +exports[`SocialShareWidget rendered with videoSharingEnabled false with videoSharingEnabledForCourse and isLibrary false and videoSharingEnabledForAll true should return null 1`] = `null`; exports[`SocialShareWidget rendered with videoSharingEnabled true and allowVideoSharing value equals false should have subtitle with text that reads Enabled 1`] = ` { describe('with default props', () => { it('should return null', () => { const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); + expect(wrapper.snapshot).toMatchSnapshot(); }); }); describe('with videoSharingEnabledForAll false and isLibrary true', () => { it('should return null', () => { const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); + expect(wrapper.snapshot).toMatchSnapshot(); }); }); describe('with videoSharingEnabledForCourse and isLibrary false and videoSharingEnabledForAll true', () => { it('should return null', () => { const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); + expect(wrapper.snapshot).toMatchSnapshot(); }); }); }); @@ -82,11 +82,11 @@ describe('SocialShareWidget', () => { }} />); it('should have setting location message', () => { - const settingLocationDisclaimer = wrapper.find('FormattedMessage').at(2).prop('defaultMessage'); + const settingLocationDisclaimer = wrapper.instance.findByType('FormattedMessage')[2].props.defaultMessage; expect(settingLocationDisclaimer).toEqual(messages.disclaimerSettingLocation.defaultMessage); }); it('should have checkbox disabled prop equal true', () => { - const disabledCheckbox = wrapper.children().at(1).prop('disabled'); + const disabledCheckbox = wrapper.shallowWrapper.props.children[1].props.disabled; expect(disabledCheckbox).toEqual(true); }); }); @@ -100,17 +100,17 @@ describe('SocialShareWidget', () => { }} />); it('should not have setting location message', () => { - const formattedMessages = wrapper.find('FormattedMessage'); + const formattedMessages = wrapper.instance.findByType('FormattedMessage'); expect(formattedMessages.length).toEqual(1); - expect(formattedMessages.at(0)).not.toEqual(messages.disclaimerSettingLocation.defaultMessage); + expect(formattedMessages[0]).not.toEqual(messages.disclaimerSettingLocation.defaultMessage); }); it('should not have override note', () => { - const formattedMessages = wrapper.find('FormattedMessage'); + const formattedMessages = wrapper.instance.findByType('FormattedMessage'); expect(formattedMessages.length).toEqual(1); - expect(formattedMessages.at(0)).not.toEqual(messages.overrideSocialSharingNote.defaultMessage); + expect(formattedMessages[0]).not.toEqual(messages.overrideSocialSharingNote.defaultMessage); }); it('should have checkbox disabled prop equal false', () => { - const disabledCheckbox = wrapper.children().at(1).prop('disabled'); + const disabledCheckbox = wrapper.shallowWrapper.props.children[1].props.disabled; expect(disabledCheckbox).toEqual(false); }); }); @@ -125,17 +125,17 @@ describe('SocialShareWidget', () => { }} />); it('should not have setting location message', () => { - const formattedMessages = wrapper.find('FormattedMessage'); + const formattedMessages = wrapper.instance.findByType('FormattedMessage'); expect(formattedMessages.length).toEqual(1); - expect(formattedMessages.at(0)).not.toEqual(messages.disclaimerSettingLocation.defaultMessage); + expect(formattedMessages[0]).not.toEqual(messages.disclaimerSettingLocation.defaultMessage); }); it('should not have override note', () => { - const formattedMessages = wrapper.find('FormattedMessage'); + const formattedMessages = wrapper.instance.findByType('FormattedMessage'); expect(formattedMessages.length).toEqual(1); - expect(formattedMessages.at(0)).not.toEqual(messages.overrideSocialSharingNote.defaultMessage); + expect(formattedMessages[0]).not.toEqual(messages.overrideSocialSharingNote.defaultMessage); }); it('should have checkbox disabled prop equal false', () => { - const disabledCheckbox = wrapper.children().at(1).prop('disabled'); + const disabledCheckbox = wrapper.shallowWrapper.props.children[1].props.disabled; expect(disabledCheckbox).toEqual(false); }); }); @@ -148,8 +148,8 @@ describe('SocialShareWidget', () => { value: true, }} />); - const subtitle = wrapper.prop('subtitle'); - expect(wrapper).toMatchSnapshot(); + const { subtitle } = wrapper.shallowWrapper.props; + expect(wrapper.snapshot).toMatchSnapshot(); expect(subtitle).toEqual('Enabled'); }); }); @@ -164,11 +164,11 @@ describe('SocialShareWidget', () => { }} />); it('should have setting location message', () => { - const settingLocationDisclaimer = wrapper.find('FormattedMessage').at(2).prop('defaultMessage'); + const settingLocationDisclaimer = wrapper.instance.findByType('FormattedMessage')[2].props.defaultMessage; expect(settingLocationDisclaimer).toEqual(messages.disclaimerSettingLocation.defaultMessage); }); it('should have checkbox disabled prop equal true', () => { - const disabledCheckbox = wrapper.children().at(1).prop('disabled'); + const disabledCheckbox = wrapper.shallowWrapper.props.children[1].props.disabled; expect(disabledCheckbox).toEqual(true); }); }); @@ -182,17 +182,17 @@ describe('SocialShareWidget', () => { }} />); it('should not have setting location message', () => { - const formattedMessages = wrapper.find('FormattedMessage'); + const formattedMessages = wrapper.instance.findByType('FormattedMessage'); expect(formattedMessages.length).toEqual(1); expect(formattedMessages.at(0)).not.toEqual(messages.disclaimerSettingLocation.defaultMessage); }); it('should not have override note', () => { - const formattedMessages = wrapper.find('FormattedMessage'); + const formattedMessages = wrapper.instance.findByType('FormattedMessage'); expect(formattedMessages.length).toEqual(1); expect(formattedMessages.at(0)).not.toEqual(messages.overrideSocialSharingNote.defaultMessage); }); it('should have checkbox disabled prop equal false', () => { - const disabledCheckbox = wrapper.children().at(1).prop('disabled'); + const disabledCheckbox = wrapper.shallowWrapper.props.children[1].props.disabled; expect(disabledCheckbox).toEqual(false); }); }); @@ -207,17 +207,17 @@ describe('SocialShareWidget', () => { }} />); it('should not have setting location message', () => { - const formattedMessages = wrapper.find('FormattedMessage'); + const formattedMessages = wrapper.instance.findByType('FormattedMessage'); expect(formattedMessages.length).toEqual(1); expect(formattedMessages.at(0)).not.toEqual(messages.disclaimerSettingLocation.defaultMessage); }); it('should not have override note', () => { - const formattedMessages = wrapper.find('FormattedMessage'); + const formattedMessages = wrapper.instance.findByType('FormattedMessage'); expect(formattedMessages.length).toEqual(1); expect(formattedMessages.at(0)).not.toEqual(messages.overrideSocialSharingNote.defaultMessage); }); it('should have checkbox disabled prop equal false', () => { - const disabledCheckbox = wrapper.children().at(1).prop('disabled'); + const disabledCheckbox = wrapper.shallowWrapper.props.children[1].props.disabled; expect(disabledCheckbox).toEqual(false); }); }); @@ -230,8 +230,8 @@ describe('SocialShareWidget', () => { value: false, }} />); - const subtitle = wrapper.prop('subtitle'); - expect(wrapper).toMatchSnapshot(); + const { subtitle } = wrapper.shallowWrapper.props; + expect(wrapper.snapshot).toMatchSnapshot(); expect(subtitle).toEqual('Disabled'); }); }); diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/__snapshots__/index.test.jsx.snap b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/__snapshots__/index.test.jsx.snap index a1f33627b..71f1a6afe 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/__snapshots__/index.test.jsx.snap @@ -268,4 +268,4 @@ exports[`ThumbnailWidget snapshots snapshots: renders as expected with default p `; -exports[`ThumbnailWidget snapshots snapshots: renders as expected with isLibrary true 1`] = `""`; +exports[`ThumbnailWidget snapshots snapshots: renders as expected with isLibrary true 1`] = `null`; diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/index.test.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/index.test.jsx index ff5d8d5fc..66309718c 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/index.test.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/ThumbnailWidget/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { selectors } from '../../../../../../data/redux'; @@ -45,32 +45,32 @@ describe('ThumbnailWidget', () => { describe('snapshots', () => { test('snapshots: renders as expected with default props', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with isLibrary true', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with a thumbnail provided', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected where thumbnail uploads are allowed', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected where videoId is valid', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected where videoId is valid and no thumbnail', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/ImportTranscriptCard.test.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/ImportTranscriptCard.test.jsx index abc7165ef..eef813dc3 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/ImportTranscriptCard.test.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/ImportTranscriptCard.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { Button, IconButton } from '@edx/paragon'; import { thunkActions } from '../../../../../../data/redux'; @@ -27,7 +27,7 @@ describe('ImportTranscriptCard', () => { describe('snapshots', () => { test('snapshots: renders as expected with default props', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); @@ -36,12 +36,12 @@ describe('ImportTranscriptCard', () => { el = shallow(); }); test('close behavior is linked to IconButton', () => { - expect(el.find(IconButton) - .props().onClick).toBeDefined(); + expect(el.instance.findByType(IconButton)[0] + .props.onClick).toBeDefined(); }); test('import behavior is linked to Button onClick', () => { - expect(el.find(Button) - .props().onClick).toEqual(props.importTranscript); + expect(el.instance.findByType(Button)[0] + .props.onClick).toEqual(props.importTranscript); }); }); describe('mapStateToProps', () => { diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/LanguageSelector.test.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/LanguageSelector.test.jsx index aaadf0645..f45665f35 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/LanguageSelector.test.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/LanguageSelector.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { LanguageSelector } from './LanguageSelector'; import { formatMessage } from '../../../../../../../testUtils'; @@ -30,14 +30,14 @@ describe('LanguageSelector', () => { describe('snapshot', () => { test('transcript option', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); describe('snapshots -- no', () => { test('transcripts no Open Languages, all should be disabled', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/Transcript.test.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/Transcript.test.jsx index 627586993..6216caefb 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/Transcript.test.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/Transcript.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import * as module from './Transcript'; @@ -57,7 +57,7 @@ describe('Transcript Component', () => { cancelDelete: jest.fn().mockName('cancelDelete'), })); expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with default props: dont show confirm delete, language is blank so delete is shown instead of action menu', () => { @@ -67,7 +67,7 @@ describe('Transcript Component', () => { cancelDelete: jest.fn().mockName('cancelDelete'), })); expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with default props: show confirm delete', () => { @@ -77,7 +77,7 @@ describe('Transcript Component', () => { cancelDelete: jest.fn().mockName('cancelDelete'), })); expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with transcriptUrl', () => { @@ -87,7 +87,7 @@ describe('Transcript Component', () => { cancelDelete: jest.fn().mockName('cancelDelete'), })); expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/TranscriptActionMenu.test.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/TranscriptActionMenu.test.jsx index 255ca1334..a22eda8a8 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/TranscriptActionMenu.test.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/TranscriptActionMenu.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { thunkActions, selectors } from '../../../../../../data/redux'; @@ -71,13 +71,13 @@ describe('TranscriptActionMenu', () => { test('snapshots: renders as expected with default props: dont show confirm delete', () => { jest.spyOn(module.hooks, 'replaceFileCallback').mockImplementationOnce(() => jest.fn().mockName('module.hooks.replaceFileCallback')); expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with transcriptUrl props: dont show confirm delete', () => { jest.spyOn(module.hooks, 'replaceFileCallback').mockImplementationOnce(() => jest.fn().mockName('module.hooks.replaceFileCallback')); expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/__snapshots__/index.test.jsx.snap b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/__snapshots__/index.test.jsx.snap index da936c920..b4bb929fd 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/__snapshots__/index.test.jsx.snap +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/__snapshots__/index.test.jsx.snap @@ -393,14 +393,16 @@ exports[`TranscriptWidget component snapshots snapshots: renders as expected wit - - + + + +
@@ -453,11 +455,13 @@ exports[`TranscriptWidget component snapshots snapshots: renders as expected wit - + + +
@@ -629,11 +633,13 @@ exports[`TranscriptWidget component snapshots snapshots: renders as expected wit - + + +
diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/index.test.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/index.test.jsx index 67f659258..74353290c 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/index.test.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/TranscriptWidget/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { RequestKeys } from '../../../../../../data/constants/requests'; @@ -101,47 +101,47 @@ describe('TranscriptWidget', () => { describe('snapshots', () => { test('snapshots: renders as expected with default props', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with allowTranscriptImport true', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with transcripts', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with transcript urls', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with transcripts and urls', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with allowTranscriptDownloads true', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshots: renders as expected with showTranscriptByDefault true', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshot: renders ErrorAlert with upload error message', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); test('snapshot: renders ErrorAlert with delete error message', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget/index.test.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget/index.test.jsx index 655fd34b6..a88f9a3fc 100644 --- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget/index.test.jsx +++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/VideoSourceWidget/index.test.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { dispatch } from 'react-redux'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../../../../testUtils'; import { VideoSourceWidget } from '.'; @@ -72,13 +72,13 @@ describe('VideoSourceWidget', () => { describe('snapshots: renders as expected with', () => { it('default props', () => { expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); it('videoSharingEnabledForCourse=true', () => { const newProps = { ...props, videoSharingEnabledForCourse: true }; expect( - shallow(), + shallow().snapshot, ).toMatchSnapshot(); }); }); @@ -95,13 +95,13 @@ describe('VideoSourceWidget', () => { const expected = hook.updateVideoId; expect(el // eslint-disable-next-line - .children().at(1).children().at(0).children().at(0) - .props().onBlur).toEqual(expected); + .shallowWrapper.props.children[1].props.children[0].props.children[0] + .props.onBlur).toEqual(expected); }); test('updateVideoURL is tied to url field onBlur', () => { const { onBlur } = el // eslint-disable-next-line - .children().at(1).children().at(0).children().at(2).props(); + .shallowWrapper.props.children[1].props.children[0].props.children[2].props; onBlur('onBlur event'); expect(hook.updateVideoURL).toHaveBeenCalledWith('onBlur event', ''); }); diff --git a/src/editors/containers/VideoEditor/index.test.jsx b/src/editors/containers/VideoEditor/index.test.jsx index 0b5d81a66..5c875cfe5 100644 --- a/src/editors/containers/VideoEditor/index.test.jsx +++ b/src/editors/containers/VideoEditor/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../testUtils'; import { selectors } from '../../data/redux'; @@ -10,7 +10,9 @@ jest.mock('../EditorContainer', () => 'EditorContainer'); jest.mock('./components/VideoEditorModal', () => 'VideoEditorModal'); jest.mock('./hooks', () => ({ - ErrorContext: jest.fn(), + ErrorContext: { + Provider: 'ErrorContext.Provider', + }, errorsHook: jest.fn(() => ({ error: 'hooks.errorsHook.error', validateEntry: jest.fn().mockName('validateEntry'), @@ -29,6 +31,11 @@ jest.mock('../../data/redux', () => ({ }, })); +jest.mock('@edx/paragon', () => ({ + ...jest.requireActual('@edx/paragon'), + Spinner: 'Spinner', +})); + describe('VideoEditor', () => { const props = { onClose: jest.fn().mockName('props.onClose'), @@ -38,10 +45,10 @@ describe('VideoEditor', () => { }; describe('snapshots', () => { test('renders as expected with default behavior', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('renders as expected with default behavior', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); describe('mapStateToProps', () => { diff --git a/src/editors/sharedComponents/BaseModal/index.test.jsx b/src/editors/sharedComponents/BaseModal/index.test.jsx index f855014c4..1afd1662c 100644 --- a/src/editors/sharedComponents/BaseModal/index.test.jsx +++ b/src/editors/sharedComponents/BaseModal/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import BaseModal from '.'; @@ -13,6 +13,6 @@ describe('BaseModal ImageUploadModal template component', () => { confirmAction: 'props.confirmAction node', footerAction: 'props.footerAction node', }; - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/sharedComponents/CodeEditor/index.test.jsx b/src/editors/sharedComponents/CodeEditor/index.test.jsx index 26e935299..d0827754c 100644 --- a/src/editors/sharedComponents/CodeEditor/index.test.jsx +++ b/src/editors/sharedComponents/CodeEditor/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { EditorState } from '@codemirror/state'; import { EditorView } from '@codemirror/view'; @@ -171,7 +171,7 @@ describe('CodeEditor', () => { test('Renders and calls Hooks ', () => { jest.spyOn(hooks, 'prepareShowBtnEscapeHTML').mockImplementation(() => ({ showBtnEscapeHTML: true, hideBtn: mockHideBtn })); // Note: ref won't show up as it is not acutaly a DOM attribute. - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); expect(hooks.createCodeMirrorDomNode).toHaveBeenCalled(); }); }); diff --git a/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.jsx b/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.jsx index f06941ba9..f8d8f7b3c 100644 --- a/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.jsx +++ b/src/editors/sharedComponents/ErrorAlerts/ErrorAlert.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import * as module from './ErrorAlert'; import { MockUseState } from '../../../testUtils'; @@ -70,13 +70,15 @@ describe('ErrorAlert component', () => { jest.clearAllMocks(); }); test('snapshot: is Null when no error (ErrorAlert)', () => { - expect(shallow(

An Error Message

)).toMatchSnapshot(); + expect(shallow(

An Error Message

).snapshot).toMatchSnapshot(); }); test('snapshot: Loads children and component when error (ErrorAlert)', () => { - expect(shallow({msg})).toMatchSnapshot(); + expect( + shallow({msg}).snapshot, + ).toMatchSnapshot(); }); test('snapshot: Does not load heading when hideHeading is true', () => { - expect(shallow({msg})).toMatchSnapshot(); + expect(shallow({msg}).snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.jsx b/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.jsx index ddb838388..c7f365b5a 100644 --- a/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.jsx +++ b/src/editors/sharedComponents/ErrorAlerts/FetchErrorAlert.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { FetchErrorAlert } from './FetchErrorAlert'; jest.mock('../../data/redux', () => ({ @@ -13,7 +13,7 @@ jest.mock('../../data/redux', () => ({ describe('FetchErrorAlert', () => { describe('Snapshots', () => { test('snapshot: is ErrorAlert with Message error (ErrorAlert)', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/sharedComponents/ErrorAlerts/UploadErrorAlert.test.jsx b/src/editors/sharedComponents/ErrorAlerts/UploadErrorAlert.test.jsx index 4365c6903..d3afb4b7a 100644 --- a/src/editors/sharedComponents/ErrorAlerts/UploadErrorAlert.test.jsx +++ b/src/editors/sharedComponents/ErrorAlerts/UploadErrorAlert.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { UploadErrorAlert } from './UploadErrorAlert'; jest.mock('../../data/redux', () => ({ @@ -13,7 +13,7 @@ jest.mock('../../data/redux', () => ({ describe('UploadErrorAlert', () => { describe('Snapshots', () => { test('snapshot: is ErrorAlert with Message error (ErrorAlert)', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/sharedComponents/ErrorAlerts/__snapshots__/ErrorAlert.test.jsx.snap b/src/editors/sharedComponents/ErrorAlerts/__snapshots__/ErrorAlert.test.jsx.snap index 8d8ecd143..2b2953062 100644 --- a/src/editors/sharedComponents/ErrorAlerts/__snapshots__/ErrorAlert.test.jsx.snap +++ b/src/editors/sharedComponents/ErrorAlerts/__snapshots__/ErrorAlert.test.jsx.snap @@ -31,4 +31,4 @@ exports[`ErrorAlert component Component Snapshots snapshot: Loads children and c `; -exports[`ErrorAlert component Component Snapshots snapshot: is Null when no error (ErrorAlert) 1`] = `""`; +exports[`ErrorAlert component Component Snapshots snapshot: is Null when no error (ErrorAlert) 1`] = `null`; diff --git a/src/editors/sharedComponents/ErrorBoundary/ErrorPage.test.jsx b/src/editors/sharedComponents/ErrorBoundary/ErrorPage.test.jsx index da0979f8a..4c7d6e085 100644 --- a/src/editors/sharedComponents/ErrorBoundary/ErrorPage.test.jsx +++ b/src/editors/sharedComponents/ErrorBoundary/ErrorPage.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { selectors } from '../../data/redux'; import { formatMessage } from '../../../testUtils'; import { ErrorPage, mapStateToProps } from './ErrorPage'; @@ -33,8 +33,8 @@ describe('Editor Page', () => { describe('rendered with empty props', () => { it('should only have one button (try again)', () => { const wrapper = shallow(); - const buttonText = wrapper.find('Button').text(); - expect(wrapper).toMatchSnapshot(); + const buttonText = wrapper.instance.findByType('Button')[0].children[0].el; + expect(wrapper.snapshot).toMatchSnapshot(); expect(buttonText).toEqual('Try again'); }); }); @@ -43,25 +43,25 @@ describe('Editor Page', () => { const wrapper = shallow(); describe('shows two buttons', () => { it('the first button should correspond to returning to the course outline', () => { - const firstButtonText = wrapper.find('Button').at(0).text(); - const secondButtonText = wrapper.find('Button').at(1).text(); - expect(wrapper).toMatchSnapshot(); + const firstButtonText = wrapper.instance.findByType('Button')[0].children[0].el; + const secondButtonText = wrapper.instance.findByType('Button')[1].children[0].el; + expect(wrapper.snapshot).toMatchSnapshot(); expect(firstButtonText).toEqual('Return to course outline'); expect(secondButtonText).toEqual('Try again'); }); it('the first button should correspond to returning to the unit page', () => { const returnToUnitPageWrapper = shallow(); - expect(returnToUnitPageWrapper).toMatchSnapshot(); - const firstButtonText = returnToUnitPageWrapper.find('Button').at(0).text(); - const secondButtonText = returnToUnitPageWrapper.find('Button').at(1).text(); - expect(returnToUnitPageWrapper).toMatchSnapshot(); + expect(returnToUnitPageWrapper.snapshot).toMatchSnapshot(); + const firstButtonText = returnToUnitPageWrapper.instance.findByType('Button')[0].children[0].el; + const secondButtonText = returnToUnitPageWrapper.instance.findByType('Button')[1].children[0].el; + expect(returnToUnitPageWrapper.snapshot).toMatchSnapshot(); expect(firstButtonText).toEqual('Return to unit page'); expect(secondButtonText).toEqual('Try again'); }); }); it('should have custom message', () => { - const customMessageText = wrapper.find('div').children().at(0).text(); - expect(wrapper).toMatchSnapshot(); + const customMessageText = wrapper.instance.findByType('div')[0].children[0].children[0].el; + expect(wrapper.snapshot).toMatchSnapshot(); expect(customMessageText).toEqual('cUStomMEssagE'); }); }); diff --git a/src/editors/sharedComponents/ErrorBoundary/index.test.jsx b/src/editors/sharedComponents/ErrorBoundary/index.test.jsx index d75ff0d60..7f6ef8129 100644 --- a/src/editors/sharedComponents/ErrorBoundary/index.test.jsx +++ b/src/editors/sharedComponents/ErrorBoundary/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { render } from '@testing-library/react'; import { logError, @@ -22,11 +22,11 @@ describe('ErrorBoundary', () => {
Yay
); - const wrapper = mount(component); - const element = wrapper.find('div'); + const { container } = render(component); + const element = container.querySelector('div'); expect(logError).toHaveBeenCalledTimes(0); - expect(element.text()).toEqual('Yay'); + expect(element.textContent).toEqual('Yay'); }); it('should render ErrorPage if it has an error', () => { @@ -38,8 +38,8 @@ describe('ErrorBoundary', () => { ); - const wrapper = mount(component); - const element = wrapper.find('p'); + const { container } = render(component); + const element = container.querySelector('p'); expect(logError).toHaveBeenCalledTimes(1); expect(logError).toHaveBeenCalledWith( new Error('booyah'), @@ -47,6 +47,6 @@ describe('ErrorBoundary', () => { stack: expect.stringContaining('ExplodingComponent'), }), ); - expect(element.text()).toEqual('Error Page'); + expect(element.textContent).toEqual('Error Page'); }); }); diff --git a/src/editors/sharedComponents/ExpandableTextArea/index.test.jsx b/src/editors/sharedComponents/ExpandableTextArea/index.test.jsx index ed227294d..9995360e9 100644 --- a/src/editors/sharedComponents/ExpandableTextArea/index.test.jsx +++ b/src/editors/sharedComponents/ExpandableTextArea/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import ExpandableTextArea from '.'; // Per https://github.com/tinymce/tinymce-react/issues/91 React unit testing in JSDOM is not supported by tinymce. @@ -24,11 +24,11 @@ describe('ExpandableTextArea', () => { }; describe('snapshots', () => { test('renders as expected with default behavior', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('renders error message', () => { const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); + expect(wrapper.snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/sharedComponents/FileInput/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/FileInput/__snapshots__/index.test.jsx.snap index 4c4fd68dc..454989b01 100644 --- a/src/editors/sharedComponents/FileInput/__snapshots__/index.test.jsx.snap +++ b/src/editors/sharedComponents/FileInput/__snapshots__/index.test.jsx.snap @@ -1,20 +1,11 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`FileInput component snapshot 1`] = ` - +
- +
`; diff --git a/src/editors/sharedComponents/FileInput/index.test.jsx b/src/editors/sharedComponents/FileInput/index.test.jsx index 45a043b41..fd2f35436 100644 --- a/src/editors/sharedComponents/FileInput/index.test.jsx +++ b/src/editors/sharedComponents/FileInput/index.test.jsx @@ -1,8 +1,10 @@ import React from 'react'; -import { mount } from 'enzyme'; +import { fireEvent, render } from '@testing-library/react'; import { FileInput } from '.'; +const mockOnChange = jest.fn(); + describe('FileInput component', () => { let el; let container; @@ -12,22 +14,23 @@ describe('FileInput component', () => { props = { acceptedFiles: '.srt', fileInput: { - addFile: jest.fn().mockName('props.fileInput.addFile'), + addFile: () => mockOnChange(), ref: (input) => { container.ref = input; }, }, }; - el = mount(); + el = render(); }); test('snapshot', () => { - expect(el).toMatchSnapshot(); + expect(el.container).toMatchSnapshot(); }); test('only accepts allowed file types', () => { - expect(el.find('input').props().accept).toEqual('.srt'); + expect(el.container.querySelector('input').accept).toEqual('.srt'); }); test('calls fileInput.addFile onChange', () => { - expect(el.find('input').props().onChange).toEqual(props.fileInput.addFile); + fireEvent.change(el.container.querySelector('input')); + expect(mockOnChange).toHaveBeenCalled(); }); test('loads ref from fileInput.ref', () => { - expect(container.ref).toEqual(el.find('input').getDOMNode()); + expect(container.ref).toEqual(el.container.querySelector('input')); }); }); diff --git a/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.test.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.test.jsx index ebdddaa56..9c2163fef 100644 --- a/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.test.jsx +++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/AltTextControls.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../testUtils'; import { AltTextControls } from './AltTextControls'; @@ -23,11 +23,11 @@ describe('AltTextControls', () => { }); describe('render', () => { test('snapshot: isDecorative=true errorProps.showAltTextSubmissionError=true', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: isDecorative=true errorProps.showAltTextSubmissionError=false', () => { props.validation.show = false; - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.test.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.test.jsx index 5b03e096b..6b44d5d09 100644 --- a/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.test.jsx +++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/DimensionControls.test.jsx @@ -1,5 +1,5 @@ import React, { useEffect } from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import * as paragon from '@edx/paragon'; import * as icons from '@edx/paragon/icons'; @@ -53,16 +53,16 @@ describe('DimensionControls', () => { jest.spyOn(hooks, 'onInputChange').mockRestore(); }); test('snapshot', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('null value: empty snapshot', () => { const el = shallow(); - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); expect(el.isEmptyRender()).toEqual(true); }); test('unlocked dimensions', () => { const el = shallow(); - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); }); }); describe('component tests for dimensions', () => { diff --git a/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/DimensionControls.test.jsx.snap b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/DimensionControls.test.jsx.snap index 546ecb13e..63613dc4c 100644 --- a/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/DimensionControls.test.jsx.snap +++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/__snapshots__/DimensionControls.test.jsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`DimensionControls render null value: empty snapshot 1`] = `""`; +exports[`DimensionControls render null value: empty snapshot 1`] = `false`; exports[`DimensionControls render snapshot 1`] = ` diff --git a/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.test.jsx b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.test.jsx index 333d2db6b..56a94ebc7 100644 --- a/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.test.jsx +++ b/src/editors/sharedComponents/ImageUploadModal/ImageSettingsModal/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../testUtils'; import { ImageSettingsModal } from '.'; @@ -43,7 +43,7 @@ describe('ImageSettingsModal', () => { }); describe('render', () => { test('snapshot', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.test.jsx b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.test.jsx index 9de790cbc..4b52b3afa 100644 --- a/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.test.jsx +++ b/src/editors/sharedComponents/ImageUploadModal/SelectImageModal/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { formatMessage } from '../../../../testUtils'; import SelectionModal from '../../SelectionModal'; @@ -89,26 +89,26 @@ describe('SelectImageModal', () => { el = shallow(); }); test('snapshot', () => { - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); }); it('provides confirm action, forwarding selectBtnProps from imgHooks', () => { - expect(el.find(SelectionModal).props().selectBtnProps).toEqual( + expect(el.instance.findByType(SelectionModal)[0].props.selectBtnProps).toEqual( expect.objectContaining({ ...hooks.imgHooks().selectBtnProps }), ); }); it('provides file upload button linked to fileInput.click', () => { - expect(el.find(SelectionModal).props().fileInput.click).toEqual( + expect(el.instance.findByType(SelectionModal)[0].props.fileInput.click).toEqual( imgHooks.fileInput.click, ); }); it('provides a SearchSort component with searchSortProps from imgHooks', () => { - expect(el.find(SelectionModal).props().searchSortProps).toEqual(imgHooks.searchSortProps); + expect(el.instance.findByType(SelectionModal)[0].props.searchSortProps).toEqual(imgHooks.searchSortProps); }); it('provides a Gallery component with galleryProps from imgHooks', () => { - expect(el.find(SelectionModal).props().galleryProps).toEqual(imgHooks.galleryProps); + expect(el.instance.findByType(SelectionModal)[0].props.galleryProps).toEqual(imgHooks.galleryProps); }); it('provides a FileInput component with fileInput props from imgHooks', () => { - expect(el.find(SelectionModal).props().fileInput).toMatchObject(imgHooks.fileInput); + expect(el.instance.findByType(SelectionModal)[0].props.fileInput).toMatchObject(imgHooks.fileInput); }); }); }); diff --git a/src/editors/sharedComponents/ImageUploadModal/index.test.jsx b/src/editors/sharedComponents/ImageUploadModal/index.test.jsx index 7c3c49dfd..723440a6b 100644 --- a/src/editors/sharedComponents/ImageUploadModal/index.test.jsx +++ b/src/editors/sharedComponents/ImageUploadModal/index.test.jsx @@ -1,6 +1,6 @@ /* eslint-disable no-import-assign */ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { keyStore } from '../../utils'; import tinyMCEKeys from '../../data/constants/tinyMCE'; @@ -168,13 +168,13 @@ describe('ImageUploadModal', () => { module.hooks = hooks; }); test('snapshot: with selection content (ImageSettingsUpload)', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: selection has no externalUrl (Select Image Modal)', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('snapshot: no selection (Select Image Modal)', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/sharedComponents/RawEditor/index.test.jsx b/src/editors/sharedComponents/RawEditor/index.test.jsx index 9db6b86af..7d3cc3018 100644 --- a/src/editors/sharedComponents/RawEditor/index.test.jsx +++ b/src/editors/sharedComponents/RawEditor/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { RawEditor } from '.'; @@ -34,12 +34,12 @@ describe('RawEditor', () => { }; test('renders as expected with default behavior', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('renders as expected with lang equal to xml', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('renders as expected with content equal to null', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/sharedComponents/SelectionModal/Gallery.test.jsx b/src/editors/sharedComponents/SelectionModal/Gallery.test.jsx index 6e0579b86..efd818be4 100644 --- a/src/editors/sharedComponents/SelectionModal/Gallery.test.jsx +++ b/src/editors/sharedComponents/SelectionModal/Gallery.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { IntlProvider } from '@edx/frontend-platform/i18n'; @@ -31,16 +31,16 @@ describe('TextEditor Image Gallery component', () => { }; const shallowWithIntl = (component) => shallow({component}); test('snapshot: not loaded, show spinner', () => { - expect(shallowWithIntl()).toMatchSnapshot(); + expect(shallowWithIntl().snapshot).toMatchSnapshot(); }); test('snapshot: loaded but no images, show empty gallery', () => { - expect(shallowWithIntl()).toMatchSnapshot(); + expect(shallowWithIntl().snapshot).toMatchSnapshot(); }); test('snapshot: loaded but search returns no images, show 0 search result gallery', () => { - expect(shallowWithIntl()).toMatchSnapshot(); + expect(shallowWithIntl().snapshot).toMatchSnapshot(); }); test('snapshot: loaded, show gallery', () => { - expect(shallowWithIntl()).toMatchSnapshot(); + expect(shallowWithIntl().snapshot).toMatchSnapshot(); }); }); }); diff --git a/src/editors/sharedComponents/SelectionModal/GalleryCard.test.jsx b/src/editors/sharedComponents/SelectionModal/GalleryCard.test.jsx index 4b3ec843c..39afe2e08 100644 --- a/src/editors/sharedComponents/SelectionModal/GalleryCard.test.jsx +++ b/src/editors/sharedComponents/SelectionModal/GalleryCard.test.jsx @@ -1,9 +1,16 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { Image } from '@edx/paragon'; import { GalleryCard } from './GalleryCard'; +jest.mock('@edx/paragon', () => ({ + ...jest.requireActual('@edx/paragon'), + Badge: 'Badge', + SelectableBox: 'SelectableBox', + Image: 'Image', +})); + describe('GalleryCard component', () => { const asset = { externalUrl: 'props.img.externalUrl', @@ -16,30 +23,30 @@ describe('GalleryCard component', () => { el = shallow(); }); test(`snapshot: dateAdded=${asset.dateAdded}`, () => { - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); }); it('loads Image with src from image external url', () => { - expect(el.find(Image).props().src).toEqual(asset.externalUrl); + expect(el.instance.findByType(Image)[0].props.src).toEqual(asset.externalUrl); }); it('snapshot with thumbnail fallback and load error', () => { el = shallow(); - el.find(Image).props().onError(); - expect(el).toMatchSnapshot(); + el.instance.findByType(Image)[0].props.onError(); + expect(el.snapshot).toMatchSnapshot(); }); it('snapshot with thumbnail fallback and no error', () => { el = shallow(); - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); }); it('snapshot with status badge', () => { el = shallow(); - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); }); it('snapshot with duration badge', () => { el = shallow(); - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); }); it('snapshot with duration transcripts', () => { el = shallow(); - expect(el).toMatchSnapshot(); + expect(el.snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/sharedComponents/SelectionModal/__snapshots__/Gallery.test.jsx.snap b/src/editors/sharedComponents/SelectionModal/__snapshots__/Gallery.test.jsx.snap index 10cddbd47..46f9b1a8a 100644 --- a/src/editors/sharedComponents/SelectionModal/__snapshots__/Gallery.test.jsx.snap +++ b/src/editors/sharedComponents/SelectionModal/__snapshots__/Gallery.test.jsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`TextEditor Image Gallery component component snapshot: loaded but no images, show empty gallery 1`] = ` - - + `; exports[`TextEditor Image Gallery component component snapshot: loaded but search returns no images, show 0 search result gallery 1`] = ` - - + `; exports[`TextEditor Image Gallery component component snapshot: loaded, show gallery 1`] = ` - - + `; exports[`TextEditor Image Gallery component component snapshot: not loaded, show spinner 1`] = ` - - + `; diff --git a/src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap b/src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap index 810913c68..426ce389f 100644 --- a/src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap +++ b/src/editors/sharedComponents/SelectionModal/__snapshots__/GalleryCard.test.jsx.snap @@ -28,7 +28,7 @@ exports[`GalleryCard component snapshot with duration badge 1`] = ` } } /> - 01:00 - +
- failed - +
-
- - Image failed to load - -
+ />
{ value: mockvalue, ref: mockref, }); - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); }); diff --git a/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap b/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap index bef0f0f25..4d585d3b6 100644 --- a/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap +++ b/src/editors/sharedComponents/TinyMceWidget/__snapshots__/index.test.jsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`TinyMceWidget snapshots ImageUploadModal is not rendered 1`] = ` - - + `; exports[`TinyMceWidget snapshots SourcecodeModal is not rendered 1`] = ` - - + `; exports[`TinyMceWidget snapshots renders as expected with default behavior 1`] = ` - - + `; diff --git a/src/editors/sharedComponents/TinyMceWidget/index.test.jsx b/src/editors/sharedComponents/TinyMceWidget/index.test.jsx index 913a0c5ed..4bfb7a081 100644 --- a/src/editors/sharedComponents/TinyMceWidget/index.test.jsx +++ b/src/editors/sharedComponents/TinyMceWidget/index.test.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { shallow } from 'enzyme'; +import { shallow } from '@edx/react-unit-test-utils'; import { selectors } from '../../data/redux'; import SourceCodeModal from '../SourceCodeModal'; import ImageUploadModal from '../ImageUploadModal'; @@ -56,6 +56,15 @@ jest.mock('./hooks', () => ({ useImages: jest.fn(() => ({ imagesRef: { current: [{ externalUrl: staticUrl }] } })), })); +jest.mock('react-redux', () => ({ + Provider: 'Provider', + connect: (mapStateToProp, mapDispatchToProps) => (component) => ({ + mapStateToProp, + mapDispatchToProps, + component, + }), +})); + describe('TinyMceWidget', () => { const props = { editorType: 'text', @@ -80,17 +89,17 @@ describe('TinyMceWidget', () => { closeSourceCodeModal: jest.fn().mockName('modal.closeModal'), }); test('renders as expected with default behavior', () => { - expect(shallow()).toMatchSnapshot(); + expect(shallow().snapshot).toMatchSnapshot(); }); test('SourcecodeModal is not rendered', () => { const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find(SourceCodeModal).length).toBe(0); + expect(wrapper.snapshot).toMatchSnapshot(); + expect(wrapper.instance.findByType(SourceCodeModal).length).toBe(0); }); test('ImageUploadModal is not rendered', () => { const wrapper = shallow(); - expect(wrapper).toMatchSnapshot(); - expect(wrapper.find(ImageUploadModal).length).toBe(0); + expect(wrapper.snapshot).toMatchSnapshot(); + expect(wrapper.instance.findByType(ImageUploadModal).length).toBe(0); }); }); describe('mapStateToProps', () => { diff --git a/src/setupTest.js b/src/setupTest.js index 0fca3d8e1..c44f32c56 100644 --- a/src/setupTest.js +++ b/src/setupTest.js @@ -1,12 +1,8 @@ /* eslint-disable import/no-extraneous-dependencies */ -import Enzyme from 'enzyme'; -import Adapter from '@wojtekmaj/enzyme-adapter-react-17'; import 'babel-polyfill'; import 'jest-canvas-mock'; -Enzyme.configure({ adapter: new Adapter() }); - /* need to mock window for tinymce on import, as it is JSDOM incompatible */ Object.defineProperty(window, 'matchMedia', { diff --git a/www/package-lock.json b/www/package-lock.json index f0a761663..c73351771 100644 --- a/www/package-lock.json +++ b/www/package-lock.json @@ -44,7 +44,7 @@ "babel-polyfill": "6.26.0", "codemirror": "^6.0.0", "fast-xml-parser": "^4.0.10", - "frontend-components-tinymce-advanced-plugins": "^1.0.0", + "frontend-components-tinymce-advanced-plugins": "^1.0.2", "lodash-es": "^4.17.21", "moment": "^2.29.4", "moment-shortformat": "^2.1.0", @@ -69,14 +69,12 @@ "@edx/frontend-build": "13.0.1", "@edx/frontend-platform": "5.5.4", "@edx/paragon": "^21.5.6", + "@edx/react-unit-test-utils": "^1.7.0", "@edx/reactifex": "^2.1.1", "@testing-library/dom": "^8.13.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^12.1.5", "@testing-library/user-event": "^13.5.0", - "@wojtekmaj/enzyme-adapter-react-17": "^0.8.0", - "enzyme": "3.11.0", - "enzyme-to-json": "^3.6.2", "eslint-import-resolver-alias": "^1.1.2", "eslint-plugin-import": "^2.26.0", "husky": "7.0.4",