feat: migrate enzyme to edx react-unit-test-utils

This commit is contained in:
Syed Ali Abbas Zaidi
2024-01-25 02:51:53 +05:00
committed by GitHub
parent 1bc4e51c22
commit dcdaace08d
108 changed files with 1155 additions and 1046 deletions

View File

@@ -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', {

View File

@@ -8,9 +8,6 @@ module.exports = createConfig('jest', {
'<rootDir>/src/setupTest.js',
],
modulePaths: ['<rootDir>/src/'],
snapshotSerializers: [
'enzyme-to-json/serializer',
],
moduleNameMapper: {
'^lodash-es$': 'lodash',
},

709
package-lock.json generated
View File

@@ -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",

View File

@@ -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",

View File

@@ -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(<Editor {...props} />)).toMatchSnapshot();
expect(shallow(<Editor {...props} />).snapshot).toMatchSnapshot();
});
test('presents error message if no relevant editor found and ref ready', () => {
expect(shallow(<Editor {...props} blockType="fAkEBlock" />)).toMatchSnapshot();
expect(shallow(<Editor {...props} blockType="fAkEBlock" />).snapshot).toMatchSnapshot();
});
test.each(Object.values(blockTypes))('renders %p editor when ref is ready', (blockType) => {
el = shallow(<Editor {...props} blockType={blockType} />);
expect(el.children().children().at(0).is(supportedEditors[blockType])).toBe(true);
expect(el.shallowWrapper.props.children.props.children.type).toBe(supportedEditors[blockType]);
});
});
describe('behavior', () => {

View File

@@ -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(<EditorPage {...props} />)).toMatchSnapshot();
expect(shallow(<EditorPage {...props} />).snapshot).toMatchSnapshot();
});
test('props besides blockType default to null', () => {
expect(shallow(<EditorPage blockType={props.blockType} />)).toMatchSnapshot();
expect(shallow(<EditorPage blockType={props.blockType} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<VideoSelector {...props} />)).toMatchSnapshot();
expect(shallow(<VideoSelector {...props} />).snapshot).toMatchSnapshot();
});
});
describe('behavior', () => {

View File

@@ -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(<VideoSelectorPage {...props} />)).toMatchSnapshot();
expect(shallow(<VideoSelectorPage {...props} />).snapshot).toMatchSnapshot();
});
test('rendering with props to null', () => {
expect(shallow(<VideoSelectorPage />)).toMatchSnapshot();
expect(shallow(<VideoSelectorPage />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<EditorFooter {...props} />)).toMatchSnapshot();
expect(shallow(<EditorFooter {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: save disabled. Show button spinner', () => {
expect(shallow(<EditorFooter {...props} disableSave />)).toMatchSnapshot();
expect(shallow(<EditorFooter {...props} disableSave />).snapshot).toMatchSnapshot();
});
test('snapshot: save failed. Show error message', () => {
expect(shallow(<EditorFooter {...props} saveFailed />)).toMatchSnapshot();
expect(shallow(<EditorFooter {...props} saveFailed />).snapshot).toMatchSnapshot();
});
test('snapshot: show feedback link', () => {
useSelector.mockReturnValueOnce('problem');
expect(shallow(<EditorFooter {...props} />)).toMatchSnapshot();
expect(shallow(<EditorFooter {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: dont show feedback link', () => {
useSelector.mockReturnValueOnce('not a Problem');
expect(shallow(<EditorFooter {...props} />)).toMatchSnapshot();
expect(shallow(<EditorFooter {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<module.EditConfirmationButtons {...props} />)).toMatchSnapshot();
expect(shallow(<module.EditConfirmationButtons {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(
<EditConfirmationButtons updateTitle={props.updateTitle} cancelEdit={props.cancelEdit} />,
);
});

View File

@@ -15,7 +15,9 @@ exports[`TitleHeader snapshots initialized 1`] = `
className="d-flex flex-row align-items-center mt-1"
>
<Truncate>
<Component />
Object {
"useSelector": [Function],
}
</Truncate>
<IconButton
alt="Edit Title"

View File

@@ -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 { formatMessage } from '../../../../../testUtils';
import { localTitleHooks } from './hooks';
@@ -9,6 +9,13 @@ import * as module from '.';
jest.mock('./hooks', () => ({
localTitleHooks: jest.fn(),
}));
jest.mock('@edx/paragon', () => ({
...jest.requireActual('@edx/paragon'),
Truncate: ({ children }) => <div>{children}</div>, // 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(<module.TitleHeader {...props} />)).toMatchSnapshot();
expect(shallow(<module.TitleHeader {...props} />).snapshot).toMatchSnapshot();
});
test('initialized', () => {
localTitleHooks.mockReturnValue(localTitleHooksProps);
expect(shallow(<module.TitleHeader {...props} isInitialized />)).toMatchSnapshot();
expect(shallow(<module.TitleHeader {...props} isInitialized />).shallowWrapper).toMatchSnapshot();
});
test('editing', () => {
localTitleHooks.mockReturnValue({ ...localTitleHooksProps, isEditing: true });
expect(shallow(<module.TitleHeader {...props} isInitialized />)).toMatchSnapshot();
expect(shallow(<module.TitleHeader {...props} isInitialized />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<EditorContainer {...props}>{testContent}</EditorContainer>),
shallow(<EditorContainer {...props}>{testContent}</EditorContainer>).snapshot,
).toMatchSnapshot();
});
test('snapshot: initialized. enable save and pass to header', () => {
expect(
shallow(<EditorContainer {...props}>{testContent}</EditorContainer>),
shallow(<EditorContainer {...props}>{testContent}</EditorContainer>).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);
});
});
});

View File

@@ -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(<AnswerOption {...props} />)).toMatchSnapshot();
expect(shallow(<AnswerOption {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders correct option with selected unselected feedback', () => {
expect(shallow(<AnswerOption {...props} problemType="choiceresponse" answer={answerWithSelectedUnselectedFeedback} />)).toMatchSnapshot();
expect(shallow(<AnswerOption {...props} problemType="choiceresponse" answer={answerWithSelectedUnselectedFeedback} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders correct option with numeric input problem', () => {
expect(shallow(<AnswerOption {...props} problemType="numericalresponse" />)).toMatchSnapshot();
expect(shallow(<AnswerOption {...props} problemType="numericalresponse" />).snapshot).toMatchSnapshot();
});
test('snapshot: renders correct option with numeric input problem and answer range', () => {
expect(shallow(<AnswerOption {...props} problemType="numericalresponse" answer={answerRange} />)).toMatchSnapshot();
expect(shallow(<AnswerOption {...props} problemType="numericalresponse" answer={answerRange} />).snapshot).toMatchSnapshot();
});
});

View File

@@ -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(<module.AnswersContainer {...props} />)).toMatchSnapshot();
expect(shallow(<module.AnswersContainer {...props} />).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', () => {
<module.AnswersContainer
{...emptyAnswerProps}
/>,
)).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', () => {
<module.AnswersContainer
{...answerRangeProps}
/>,
)).toMatchSnapshot();
).snapshot).toMatchSnapshot();
});
});
test('snapshot: numeric problems: answer range/answer select button: multiple answers disables range.', () => {
@@ -125,7 +125,7 @@ describe('AnswersContainer', () => {
<module.AnswersContainer
{...answersProps}
/>,
)).toMatchSnapshot();
).snapshot).toMatchSnapshot();
});
});

View File

@@ -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(<Checker {...props} />)).toMatchSnapshot();
expect(shallow(<Checker {...props} />).snapshot).toMatchSnapshot();
});
test('with multiple answers', () => {
expect(shallow(<Checker {...props} hasSingleAnswer={false} />)).toMatchSnapshot();
expect(shallow(<Checker {...props} hasSingleAnswer={false} />).snapshot).toMatchSnapshot();
});
test('with disabled', () => {
expect(shallow(<Checker {...props} disabled />)).toMatchSnapshot();
expect(shallow(<Checker {...props} disabled />).snapshot).toMatchSnapshot();
});
});

View File

@@ -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(<FeedbackBox {...props} />)).toMatchSnapshot();
expect(shallow(<FeedbackBox {...props} />).snapshot).toMatchSnapshot();
});
test('renders as expected with a numeric input problem', () => {
expect(shallow(<FeedbackBox {...props} problemType="numericalresponse" />)).toMatchSnapshot();
expect(shallow(<FeedbackBox {...props} problemType="numericalresponse" />).snapshot).toMatchSnapshot();
});
test('renders as expected with a multi select problem', () => {
expect(shallow(<FeedbackBox {...props} problemType="choiceresponse" />)).toMatchSnapshot();
expect(shallow(<FeedbackBox {...props} problemType="choiceresponse" />).snapshot).toMatchSnapshot();
});
});

View File

@@ -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(<FeedbackControl {...props} />)).toMatchSnapshot();
expect(shallow(<FeedbackControl {...props} />).snapshot).toMatchSnapshot();
});
});

View File

@@ -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(<ExplanationWidget {...props} />)).toMatchSnapshot();
expect(shallow(<ExplanationWidget {...props} />).snapshot).toMatchSnapshot();
});
});
describe('mapStateToProps', () => {

View File

@@ -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(<QuestionWidget {...props} />)).toMatchSnapshot();
expect(shallow(<QuestionWidget {...props} />).snapshot).toMatchSnapshot();
});
});
describe('mapStateToProps', () => {

View File

@@ -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(<CardSection summary="summary" isCardCollapsibleOpen><h1>Section Text</h1></CardSection>)).toMatchSnapshot();
expect(shallow(<CardSection summary="summary" isCardCollapsibleOpen><h1>Section Text</h1></CardSection>).snapshot).toMatchSnapshot();
});
test('closed', () => {
expect(shallow(<CardSection isCardCollapsibleOpen={false}><h1>Section Text</h1></CardSection>)).toMatchSnapshot();
expect(
shallow(<CardSection isCardCollapsibleOpen={false}><h1>Section Text</h1></CardSection>).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -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 = (<h1>My test content</h1>);
test('snapshot: renders correct', () => {
expect(shallow(<SettingsOption title="Settings Option Title" summary="Settings Option Summary">{children}</SettingsOption>)).toMatchSnapshot();
expect(shallow(<SettingsOption title="Settings Option Title" summary="Settings Option Summary">{children}</SettingsOption>).snapshot).toMatchSnapshot();
});
});
describe('with additional sections', () => {
@@ -17,7 +17,7 @@ describe('SettingsOption', () => {
<SettingsOption title="Settings Option Title" summary="Settings Option Summary" extraSections={sections}>
{children}
</SettingsOption>,
)).toMatchSnapshot();
).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`CardSection closed 1`] = `""`;
exports[`CardSection closed 1`] = `null`;
exports[`CardSection open 1`] = `
<Card.Section

View File

@@ -89,17 +89,21 @@ exports[`SettingsOption with additional sections snapshot: renders correct 1`] =
First Section
</h1>
</CardSection>
<CardSection
isCardCollapsibleOpen={false}
key="settingsOption-Settings Option Title-0"
none={false}
summary={null}
/>
<CardSection
isCardCollapsibleOpen={false}
key="settingsOption-Settings Option Title-1"
none={false}
summary={null}
/>
<Fragment>
<CardSection
isCardCollapsibleOpen={false}
key="settingsOption-Settings Option Title-0"
none={false}
summary={null}
/>
</Fragment>
<Fragment>
<CardSection
isCardCollapsibleOpen={false}
key="settingsOption-Settings Option Title-1"
none={false}
summary={null}
/>
</Fragment>
</Card>
`;

View File

@@ -25,6 +25,7 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget for Advanced
problemType="stringresponse"
/>
</div>
<Fragment />
<div>
<Advanced
open={false}
@@ -108,6 +109,7 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget page 1`] = `
problemType="stringresponse"
/>
</div>
<Fragment />
<div>
<Advanced
open={true}
@@ -191,6 +193,7 @@ exports[`SettingsWidget snapshot snapshot: renders Settings widget page advanced
problemType="stringresponse"
/>
</div>
<Fragment />
<div>
<Advanced
open={false}

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { showAdvancedSettingsCards } from './hooks';
import { SettingsWidget, mapDispatchToProps } from '.';
import { ProblemTypeKeys } from '../../../../../data/constants/problem';
@@ -50,7 +50,7 @@ describe('SettingsWidget', () => {
setResetTrue: jest.fn().mockName('showAdvancedSettingsCards.setResetTrue'),
};
showAdvancedSettingsCards.mockReturnValue(showAdvancedSettingsCardsProps);
expect(shallow(<SettingsWidget {...props} />)).toMatchSnapshot();
expect(shallow(<SettingsWidget {...props} />).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(<SettingsWidget {...props} />)).toMatchSnapshot();
expect(shallow(<SettingsWidget {...props} />).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(<SettingsWidget problemType={ProblemTypeKeys.ADVANCED} {...props} />)).toMatchSnapshot();
expect(shallow(<SettingsWidget problemType={ProblemTypeKeys.ADVANCED} {...props} />).snapshot).toMatchSnapshot();
});
});

View File

@@ -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(<GeneralFeedbackCard {...props} />)).toMatchSnapshot();
expect(shallow(<GeneralFeedbackCard {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<GroupFeedbackRow {...props} />)).toMatchSnapshot();
expect(shallow(<GroupFeedbackRow {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -18,11 +18,12 @@ exports[`GroupFeedbackRow snapshot snapshot: renders hints row 1`] = `
alt="Delete answer"
iconAs="Icon"
onClick={[MockFunction handleDelete]}
src="DeleteOutline"
variant="primary"
/>
</div>
</ActionRow>
<Component
<Form.CheckboxSet
onChange={[MockFunction handleAnswersSelectedChange]}
value={
Array [
@@ -34,7 +35,7 @@ exports[`GroupFeedbackRow snapshot snapshot: renders hints row 1`] = `
<Row
className="mx-0"
>
<Form.Checkbox
<Form.CheckboxSet
checked={-1}
className="mr-4 mt-1"
isValid={false}
@@ -42,8 +43,8 @@ exports[`GroupFeedbackRow snapshot snapshot: renders hints row 1`] = `
<div
className="x-small"
/>
</Form.Checkbox>
<Form.Checkbox
</Form.CheckboxSet>
<Form.CheckboxSet
checked={-1}
className="mr-4 mt-1"
isValid={false}
@@ -51,8 +52,8 @@ exports[`GroupFeedbackRow snapshot snapshot: renders hints row 1`] = `
<div
className="x-small"
/>
</Form.Checkbox>
<Form.Checkbox
</Form.CheckboxSet>
<Form.CheckboxSet
checked={-1}
className="mr-4 mt-1"
isValid={false}
@@ -60,8 +61,8 @@ exports[`GroupFeedbackRow snapshot snapshot: renders hints row 1`] = `
<div
className="x-small"
/>
</Form.Checkbox>
<Form.Checkbox
</Form.CheckboxSet>
<Form.CheckboxSet
checked={-1}
className="mr-4 mt-1"
isValid={false}
@@ -69,8 +70,8 @@ exports[`GroupFeedbackRow snapshot snapshot: renders hints row 1`] = `
<div
className="x-small"
/>
</Form.Checkbox>
</Form.CheckboxSet>
</Row>
</Component>
</Form.CheckboxSet>
</div>
`;

View File

@@ -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(<GroupFeedbackCard {...props} />)).toMatchSnapshot();
expect(shallow(<GroupFeedbackCard {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders groupFeedbacks setting card one groupFeedback', () => {
const groupFeedbacksCardHooksProps = {
@@ -64,7 +64,7 @@ describe('HintsCard', () => {
};
groupFeedbackCardHooks.mockReturnValue(groupFeedbacksCardHooksProps);
expect(shallow(<GroupFeedbackCard {...props} groupFeedbacks={groupFeedbacks1} />)).toMatchSnapshot();
expect(shallow(<GroupFeedbackCard {...props} groupFeedbacks={groupFeedbacks1} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders groupFeedbacks setting card multiple groupFeedbacks', () => {
const groupFeedbacksCardHooksProps = {
@@ -76,7 +76,7 @@ describe('HintsCard', () => {
};
groupFeedbackCardHooks.mockReturnValue(groupFeedbacksCardHooksProps);
expect(shallow(<GroupFeedbackCard {...props} groupFeedbacks={groupFeedbacks2} />)).toMatchSnapshot();
expect(shallow(<GroupFeedbackCard {...props} groupFeedbacks={groupFeedbacks2} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<HintRow {...props} />)).toMatchSnapshot();
expect(shallow(<HintRow {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<HintsCard {...props} />)).toMatchSnapshot();
expect(shallow(<HintsCard {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders hints setting card one hint', () => {
const hintsCardHooksProps = {
@@ -61,7 +61,7 @@ describe('HintsCard', () => {
};
hintsCardHooks.mockReturnValue(hintsCardHooksProps);
expect(shallow(<HintsCard {...props} hints={hints1} />)).toMatchSnapshot();
expect(shallow(<HintsCard {...props} hints={hints1} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders hints setting card multiple hints', () => {
const hintsCardHooksProps = {
@@ -73,7 +73,7 @@ describe('HintsCard', () => {
};
hintsCardHooks.mockReturnValue(hintsCardHooksProps);
expect(shallow(<HintsCard {...props} hints={hints2} />)).toMatchSnapshot();
expect(shallow(<HintsCard {...props} hints={hints2} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<RandomizationCard {...props} />)).toMatchSnapshot();
expect(shallow(<RandomizationCard {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders randomization setting card with default randomization', () => {
expect(shallow(<RandomizationCard {...props} randomization={null} />)).toMatchSnapshot();
expect(shallow(<RandomizationCard {...props} randomization={null} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders randomization setting card with randomization null', () => {
expect(shallow(<RandomizationCard {...props} randomization={null} defaultValue={null} />)).toMatchSnapshot();
expect(
shallow(<RandomizationCard {...props} randomization={null} defaultValue={null} />).snapshot,
).toMatchSnapshot();
});
});
});

View File

@@ -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(<ResetCard {...props} />)).toMatchSnapshot();
expect(shallow(<ResetCard {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders reset true setting card', () => {
expect(shallow(<ResetCard {...props} showResetButton />)).toMatchSnapshot();
expect(shallow(<ResetCard {...props} showResetButton />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<ScoringCard {...props} />)).toMatchSnapshot();
expect(shallow(<ScoringCard {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: scoring setting card zero zero weight', () => {
expect(shallow(<ScoringCard
@@ -52,7 +52,7 @@ describe('ScoringCard', () => {
...scoring,
weight: 0,
}}
/>)).toMatchSnapshot();
/>).snapshot).toMatchSnapshot();
});
test('snapshot: scoring setting card max attempts', () => {
expect(shallow(<ScoringCard
@@ -64,7 +64,7 @@ describe('ScoringCard', () => {
number: 0,
},
}}
/>)).toMatchSnapshot();
/>).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<ShowAnswerCard {...props} />)).toMatchSnapshot();
expect(shallow(<ShowAnswerCard {...props} />).snapshot).toMatchSnapshot();
});
});
describe('mapStateToProps', () => {

View File

@@ -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(<SwitchToAdvancedEditorCard switchToAdvancedEditor={mockSwitchToAdvancedEditor} problemType="stringresponse" />),
shallow(<SwitchToAdvancedEditorCard switchToAdvancedEditor={mockSwitchToAdvancedEditor} problemType="stringresponse" />).snapshot,
).toMatchSnapshot();
});
test('snapshot: SwitchToAdvancedEditorCard returns null', () => {
expect(
shallow(<SwitchToAdvancedEditorCard switchToAdvancedEditor={mockSwitchToAdvancedEditor} problemType="advanced" />),
shallow(<SwitchToAdvancedEditorCard switchToAdvancedEditor={mockSwitchToAdvancedEditor} problemType="advanced" />).snapshot,
).toMatchSnapshot();
});

View File

@@ -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(<TimerCard {...props} />)).toMatchSnapshot();
expect(shallow(<TimerCard {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<TypeCard {...props} />)).toMatchSnapshot();
expect(shallow(<TypeCard {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<TypeRow {...props} />)).toMatchSnapshot();
expect(shallow(<TypeRow {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders type row setting card not selected', () => {
expect(shallow(<TypeRow {...props} selected={false} />)).toMatchSnapshot();
expect(shallow(<TypeRow {...props} selected={false} />).snapshot).toMatchSnapshot();
});
test('snapshot: renders type row setting card last row', () => {
expect(shallow(<TypeRow {...props} lastRow />)).toMatchSnapshot();
expect(shallow(<TypeRow {...props} lastRow />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -8,112 +8,114 @@ exports[`ShowAnswerCard snapshot snapshot: show answer setting card 1`] = `
summary="After Some Number of Attempts"
title="Show answer"
>
<div
className="pb-2"
>
<span>
<FormattedMessage
defaultMessage="Define when learners can see the correct answer."
description="Show Answer settings card text"
id="authoring.problemeditor.settings.showAnswer.text"
/>
</span>
</div>
<div
className="pb-4"
>
<Hyperlink
destination="SoMEeNDpOinT/settings/advanced/sOMEcouRseId#showanswer"
target="_blank"
<Fragment>
<div
className="pb-2"
>
<FormattedMessage
defaultMessage="Set a default value in advanced settings"
description="Advanced settings link text"
id="authoring.problemeditor.settings.advancedSettingLink.text"
/>
</Hyperlink>
</div>
<Form.Group
className="pb-0 mb-0"
>
<Form.Control
as="select"
onChange={[MockFunction useAnswerSettings.handleShowAnswerChange]}
value="after_attempts"
<span>
<FormattedMessage
defaultMessage="Define when learners can see the correct answer."
description="Show Answer settings card text"
id="authoring.problemeditor.settings.showAnswer.text"
/>
</span>
</div>
<div
className="pb-4"
>
<option
key="always"
value="always"
<Hyperlink
destination="SoMEeNDpOinT/settings/advanced/sOMEcouRseId#showanswer"
target="_blank"
>
Always
</option>
<option
key="answered"
value="answered"
>
Answered
</option>
<option
key="attempted"
value="attempted"
>
Attempted or Past Due
</option>
<option
key="closed"
value="closed"
>
Closed
</option>
<option
key="finished"
value="finished"
>
Finished (Default)
</option>
<option
key="correct_or_past_due"
value="correct_or_past_due"
>
Correct or Past Due
</option>
<option
key="past_due"
value="past_due"
>
Past Due
</option>
<option
key="never"
value="never"
>
Never
</option>
<option
key="after_attempts"
<FormattedMessage
defaultMessage="Set a default value in advanced settings"
description="Advanced settings link text"
id="authoring.problemeditor.settings.advancedSettingLink.text"
/>
</Hyperlink>
</div>
<Form.Group
className="pb-0 mb-0"
>
<Form.Control
as="select"
onChange={[MockFunction useAnswerSettings.handleShowAnswerChange]}
value="after_attempts"
>
After Some Number of Attempts
</option>
<option
key="after_all_attempts"
value="after_all_attempts"
>
After All Attempts
</option>
<option
key="after_all_attempts_or_correct"
value="after_all_attempts_or_correct"
>
After All Attempts or Correct
</option>
<option
key="attempted_no_past_due"
value="attempted_no_past_due"
>
Attempted
</option>
</Form.Control>
</Form.Group>
<option
key="always"
value="always"
>
Always
</option>
<option
key="answered"
value="answered"
>
Answered
</option>
<option
key="attempted"
value="attempted"
>
Attempted or Past Due
</option>
<option
key="closed"
value="closed"
>
Closed
</option>
<option
key="finished"
value="finished"
>
Finished (Default)
</option>
<option
key="correct_or_past_due"
value="correct_or_past_due"
>
Correct or Past Due
</option>
<option
key="past_due"
value="past_due"
>
Past Due
</option>
<option
key="never"
value="never"
>
Never
</option>
<option
key="after_attempts"
value="after_attempts"
>
After Some Number of Attempts
</option>
<option
key="after_all_attempts"
value="after_all_attempts"
>
After All Attempts
</option>
<option
key="after_all_attempts_or_correct"
value="after_all_attempts_or_correct"
>
After All Attempts or Correct
</option>
<option
key="attempted_no_past_due"
value="attempted_no_past_due"
>
Attempted
</option>
</Form.Control>
</Form.Group>
</Fragment>
</SettingsOption>
`;

View File

@@ -56,4 +56,4 @@ exports[`SwitchToAdvancedEditorCard snapshot snapshot: SwitchToAdvancedEditorCar
</Card>
`;
exports[`SwitchToAdvancedEditorCard snapshot snapshot: SwitchToAdvancedEditorCard returns null 1`] = `""`;
exports[`SwitchToAdvancedEditorCard snapshot snapshot: SwitchToAdvancedEditorCard returns null 1`] = `null`;

View File

@@ -5,7 +5,7 @@ exports[`EditorProblemView component renders raw editor 1`] = `
getContent={[Function]}
returnFunction={null}
>
<Component
<AlertModal
footerNode={
<ActionRow>
<Button
@@ -40,7 +40,7 @@ exports[`EditorProblemView component renders raw editor 1`] = `
description="Explanation in body of mismatched settings modal"
id="authoring.problemEditor.editProblemView.saveWarningModal.olxSettingDiscrepancy.body.explanation"
/>
</Component>
</AlertModal>
<div
className="editProblemView d-flex flex-row flex-nowrap justify-content-end"
>
@@ -74,7 +74,7 @@ exports[`EditorProblemView component renders simple view 1`] = `
getContent={[Function]}
returnFunction={null}
>
<Component
<AlertModal
footerNode={
<ActionRow>
<Button
@@ -102,21 +102,23 @@ exports[`EditorProblemView component renders simple view 1`] = `
onClose={[Function]}
title="No answer specified"
>
<div>
<FormattedMessage
defaultMessage="Are you sure you want to exit the editor?"
description="Question in body of save warning modal"
id="authoring.problemEditor.editProblemView.saveWarningModal.body.question"
/>
</div>
<div>
<FormattedMessage
defaultMessage="No correct answer has been specified."
description="Explanation in body of no answer modal"
id="authoring.problemEditor.editProblemView.saveWarningModal.noAnswer.body.explanation"
/>
</div>
</Component>
<Fragment>
<div>
<FormattedMessage
defaultMessage="Are you sure you want to exit the editor?"
description="Question in body of save warning modal"
id="authoring.problemEditor.editProblemView.saveWarningModal.body.question"
/>
</div>
<div>
<FormattedMessage
defaultMessage="No correct answer has been specified."
description="Explanation in body of no answer modal"
id="authoring.problemEditor.editProblemView.saveWarningModal.noAnswer.body.explanation"
/>
</div>
</Fragment>
</AlertModal>
<div
className="editProblemView d-flex flex-row flex-nowrap justify-content-end"
>

View File

@@ -1,11 +1,19 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { EditProblemView } from '.';
import AnswerWidget from './AnswerWidget';
import { ProblemTypeKeys } from '../../../../data/constants/problem';
import RawEditor from '../../../../sharedComponents/RawEditor';
import { formatMessage } from '../../../../../testUtils';
jest.mock('@edx/paragon', () => ({
...jest.requireActual('@edx/paragon'),
Container: 'Container',
Button: 'Button',
AlertModal: 'AlertModal',
ActionRow: 'ActionRow',
}));
describe('EditorProblemView component', () => {
test('renders simple view', () => {
const wrapper = shallow(<EditProblemView
@@ -14,9 +22,11 @@ describe('EditorProblemView component', () => {
assets={{}}
intl={{ formatMessage }}
/>);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find(AnswerWidget).length).toBe(1);
expect(wrapper.find(RawEditor).length).toBe(0);
expect(wrapper.snapshot).toMatchSnapshot();
const AnswerWidgetComponent = wrapper.shallowWrapper.props.children[1].props.children[1].props.children;
expect(AnswerWidgetComponent.props.problemType).toBe(ProblemTypeKeys.SINGLESELECT);
expect(wrapper.instance.findByType(RawEditor).length).toBe(0);
});
test('renders raw editor', () => {
@@ -26,8 +36,8 @@ describe('EditorProblemView component', () => {
assets={{}}
intl={{ formatMessage }}
/>);
expect(wrapper).toMatchSnapshot();
expect(wrapper.find(AnswerWidget).length).toBe(0);
expect(wrapper.find(RawEditor).length).toBe(1);
expect(wrapper.snapshot).toMatchSnapshot();
expect(wrapper.instance.findByType(AnswerWidget).length).toBe(0);
expect(wrapper.instance.findByType(RawEditor).length).toBe(1);
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { Button } from '@edx/paragon';
import { formatMessage } from '../../../../../../testUtils';
@@ -22,7 +22,7 @@ describe('SelectTypeFooter', () => {
};
test('snapshot', () => {
expect(shallow(<module.SelectTypeFooter {...props} />)).toMatchSnapshot();
expect(shallow(<module.SelectTypeFooter {...props} />).snapshot).toMatchSnapshot();
});
describe('behavior', () => {
@@ -32,12 +32,13 @@ describe('SelectTypeFooter', () => {
});
test('close behavior is linked to modal onCancel', () => {
const expected = props.onCancel;
expect(el.find(Button).first().props().onClick)
expect(el.instance.findByType(Button)[0].props.onClick)
.toEqual(expected);
});
test('select behavior is linked to modal onSelect', () => {
const expected = hooks.onSelect(props.selected, props.updateField);
expect(el.find(Button).last().props().onClick)
const button = el.instance.findByType(Button);
expect(button[button.length - 1].props.onClick)
.toEqual(expected);
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { IconButton } from '@edx/paragon';
import * as module from '.';
import { handleCancel } from '../../../../EditorContainer/hooks';
@@ -16,7 +16,7 @@ describe('SelectTypeWrapper', () => {
};
test('snapshot', () => {
expect(shallow(<module.SelectTypeWrapper {...props} />)).toMatchSnapshot();
expect(shallow(<module.SelectTypeWrapper {...props} />).snapshot).toMatchSnapshot();
});
describe('behavior', () => {
@@ -26,7 +26,7 @@ describe('SelectTypeWrapper', () => {
});
test('close behavior is linked to modal onClose', () => {
const expected = handleCancel({ onClose: props.onClose });
expect(el.find(IconButton).props().onClick)
expect(el.instance.findByType(IconButton)[0].props.onClick)
.toEqual(expected);
});
});

View File

@@ -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 './AdvanceTypeSelect';
@@ -13,42 +13,42 @@ describe('AdvanceTypeSelect', () => {
describe('snapshots', () => {
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<module.AdvanceTypeSelect {...props} />),
shallow(<module.AdvanceTypeSelect {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is circuitschematic', () => {
expect(
shallow(<module.AdvanceTypeSelect {...props} selected="circuitschematic" />),
shallow(<module.AdvanceTypeSelect {...props} selected="circuitschematic" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is customgrader', () => {
expect(
shallow(<module.AdvanceTypeSelect {...props} selected="customgrader" />),
shallow(<module.AdvanceTypeSelect {...props} selected="customgrader" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is drag_and_drop', () => {
expect(
shallow(<module.AdvanceTypeSelect {...props} selected="drag_and_drop" />),
shallow(<module.AdvanceTypeSelect {...props} selected="drag_and_drop" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is formularesponse', () => {
expect(
shallow(<module.AdvanceTypeSelect {...props} selected="formularesponse" />),
shallow(<module.AdvanceTypeSelect {...props} selected="formularesponse" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is imageresponse', () => {
expect(
shallow(<module.AdvanceTypeSelect {...props} selected="imageresponse" />),
shallow(<module.AdvanceTypeSelect {...props} selected="imageresponse" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is jsinput_response', () => {
expect(
shallow(<module.AdvanceTypeSelect {...props} selected="jsinput_response" />),
shallow(<module.AdvanceTypeSelect {...props} selected="jsinput_response" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is problem_with_hint', () => {
expect(
shallow(<module.AdvanceTypeSelect {...props} selected="problem_with_hint" />),
shallow(<module.AdvanceTypeSelect {...props} selected="problem_with_hint" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -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 './Preview';
@@ -12,32 +12,32 @@ describe('Preview', () => {
describe('snapshots', () => {
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<module.Preview {...props} />),
shallow(<module.Preview {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is stringresponse', () => {
expect(
shallow(<module.Preview {...props} problemType="stringresponse" />),
shallow(<module.Preview {...props} problemType="stringresponse" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is numericalresponse', () => {
expect(
shallow(<module.Preview {...props} problemType="numericalresponse" />),
shallow(<module.Preview {...props} problemType="numericalresponse" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is optionresponse', () => {
expect(
shallow(<module.Preview {...props} problemType="optionresponse" />),
shallow(<module.Preview {...props} problemType="optionresponse" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is choiceresponse', () => {
expect(
shallow(<module.Preview {...props} problemType="choiceresponse" />),
shallow(<module.Preview {...props} problemType="choiceresponse" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with problemType is multiplechoiceresponse', () => {
expect(
shallow(<module.Preview {...props} problemType="multiplechoiceresponse" />),
shallow(<module.Preview {...props} problemType="multiplechoiceresponse" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { ProblemTypeKeys } from '../../../../../data/constants/problem';
import * as module from './ProblemTypeSelect';
@@ -13,27 +13,27 @@ describe('ProblemTypeSelect', () => {
test('SINGLESELECT', () => {
expect(shallow(
<module.ProblemTypeSelect {...props} selected={ProblemTypeKeys.SINGLESELECT} />,
)).toMatchSnapshot();
).snapshot).toMatchSnapshot();
});
test('MULTISELECT', () => {
expect(shallow(
<module.ProblemTypeSelect {...props} selected={ProblemTypeKeys.MULTISELECT} />,
)).toMatchSnapshot();
).snapshot).toMatchSnapshot();
});
test('DROPDOWN', () => {
expect(shallow(
<module.ProblemTypeSelect {...props} selected={ProblemTypeKeys.DROPDOWN} />,
)).toMatchSnapshot();
).snapshot).toMatchSnapshot();
});
test('NUMERIC', () => {
expect(shallow(
<module.ProblemTypeSelect {...props} selected={ProblemTypeKeys.NUMERIC} />,
)).toMatchSnapshot();
).snapshot).toMatchSnapshot();
});
test('TEXTINPUT', () => {
expect(shallow(
<module.ProblemTypeSelect {...props} selected={ProblemTypeKeys.TEXTINPUT} />,
)).toMatchSnapshot();
).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Preview snapshots snapshots: renders as expected with default props 1`] = `""`;
exports[`Preview snapshots snapshots: renders as expected with default props 1`] = `null`;
exports[`Preview snapshots snapshots: renders as expected with problemType is choiceresponse 1`] = `
<Container

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import * as module from '.';
jest.mock('./hooks', () => ({
@@ -16,6 +16,6 @@ describe('SelectTypeModal', () => {
};
test('snapshot', () => {
expect(shallow(<module.SelectTypeModal {...props} />)).toMatchSnapshot();
expect(shallow(<module.SelectTypeModal {...props} />).snapshot).toMatchSnapshot();
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { Spinner } from '@edx/paragon';
import { thunkActions, selectors } from '../../data/redux';
import { RequestKeys } from '../../data/constants/requests';
@@ -52,23 +52,23 @@ describe('ProblemEditor', () => {
};
describe('snapshots', () => {
test('renders as expected with default behavior', () => {
expect(shallow(<ProblemEditor {...props} />)).toMatchSnapshot();
expect(shallow(<ProblemEditor {...props} />).snapshot).toMatchSnapshot();
});
test('block loaded, studio view and assets not yet loaded, Spinner appears', () => {
const wrapper = shallow(<ProblemEditor {...props} blockFinished />);
expect(wrapper.containsMatchingElement(<Spinner />)).toEqual(true);
expect(wrapper.instance.findByType(Spinner)).toBeTruthy();
});
test('studio view loaded, block and assets not yet loaded, Spinner appears', () => {
const wrapper = shallow(<ProblemEditor {...props} studioViewFinished />);
expect(wrapper.containsMatchingElement(<Spinner />)).toEqual(true);
expect(wrapper.instance.findByType(Spinner)).toBeTruthy();
});
test('assets loaded, block and studio view not yet loaded, Spinner appears', () => {
const wrapper = shallow(<ProblemEditor {...props} assetsFinished />);
expect(wrapper.containsMatchingElement(<Spinner />)).toEqual(true);
expect(wrapper.instance.findByType(Spinner)).toBeTruthy();
});
test('advanceSettings loaded, block and studio view not yet loaded, Spinner appears', () => {
const wrapper = shallow(<ProblemEditor {...props} advancedSettingsFinished />);
expect(wrapper.containsMatchingElement(<Spinner />)).toEqual(true);
expect(wrapper.instance.findByType(Spinner)).toBeTruthy();
});
test('block failed, message appears', () => {
const wrapper = shallow(<ProblemEditor
@@ -79,7 +79,7 @@ describe('ProblemEditor', () => {
advancedSettingsFinished
blockFailed
/>);
expect(wrapper).toMatchSnapshot();
expect(wrapper.snapshot).toMatchSnapshot();
});
test('renders SelectTypeModal', () => {
const wrapper = shallow(<ProblemEditor
@@ -89,7 +89,7 @@ describe('ProblemEditor', () => {
assetsFinished
advancedSettingsFinished
/>);
expect(wrapper.find('SelectTypeModal')).toHaveLength(1);
expect(wrapper.instance.findByType('SelectTypeModal')).toHaveLength(1);
});
test('renders EditProblemView', () => {
const wrapper = shallow(<ProblemEditor
@@ -100,7 +100,7 @@ describe('ProblemEditor', () => {
assetsFinished
advancedSettingsFinished
/>);
expect(wrapper.find('EditProblemView')).toHaveLength(1);
expect(wrapper.instance.findByType('EditProblemView')).toHaveLength(1);
});
});

View File

@@ -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';
@@ -85,16 +85,16 @@ describe('TextEditor', () => {
};
describe('snapshots', () => {
test('renders as expected with default behavior', () => {
expect(shallow(<TextEditor {...props} />)).toMatchSnapshot();
expect(shallow(<TextEditor {...props} />).snapshot).toMatchSnapshot();
});
test('not yet loaded, Spinner appears', () => {
expect(shallow(<TextEditor {...props} assetsFinished={false} />)).toMatchSnapshot();
expect(shallow(<TextEditor {...props} assetsFinished={false} />).snapshot).toMatchSnapshot();
});
test('loaded, raw editor', () => {
expect(shallow(<TextEditor {...props} isRaw />)).toMatchSnapshot();
expect(shallow(<TextEditor {...props} isRaw />).snapshot).toMatchSnapshot();
});
test('block failed to load, Toast is shown', () => {
expect(shallow(<TextEditor {...props} blockFailed />)).toMatchSnapshot();
expect(shallow(<TextEditor {...props} blockFailed />).snapshot).toMatchSnapshot();
});
});

View File

@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`VideoEditor snapshots renders as expected with default behavior 1`] = `
<Component
<ErrorContext.Provider
value="hooks.errorsHook.error"
>
<EditorContainer
@@ -26,11 +26,11 @@ exports[`VideoEditor snapshots renders as expected with default behavior 1`] = `
/>
</div>
</EditorContainer>
</Component>
</ErrorContext.Provider>
`;
exports[`VideoEditor snapshots renders as expected with default behavior 2`] = `
<Component
<ErrorContext.Provider
value="hooks.errorsHook.error"
>
<EditorContainer
@@ -46,5 +46,5 @@ exports[`VideoEditor snapshots renders as expected with default behavior 2`] = `
/>
</div>
</EditorContainer>
</Component>
</ErrorContext.Provider>
`;

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import * as module from './ErrorSummary';
@@ -17,11 +17,11 @@ describe('ErrorSummary', () => {
});
test('snapshots: renders as expected when there are no errors', () => {
jest.spyOn(module, 'showAlert').mockReturnValue(false);
expect(shallow(<module.ErrorSummary />)).toMatchSnapshot();
expect(shallow(<module.ErrorSummary />).snapshot).toMatchSnapshot();
});
test('snapshots: renders as expected when there are errors', () => {
jest.spyOn(module, 'showAlert').mockReturnValue(true);
expect(shallow(<module.ErrorSummary />)).toMatchSnapshot();
expect(shallow(<module.ErrorSummary />).snapshot).toMatchSnapshot();
});
});
describe('hasNoError', () => {

View File

@@ -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 { CollapsibleFormWidget } from './CollapsibleFormWidget';
@@ -16,12 +16,12 @@ describe('CollapsibleFormWidget', () => {
const testContent = (<p>Some test string</p>);
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<CollapsibleFormWidget {...props}>{testContent}</CollapsibleFormWidget>),
shallow(<CollapsibleFormWidget {...props}>{testContent}</CollapsibleFormWidget>).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders with open={true} when there is error', () => {
expect(
shallow(<CollapsibleFormWidget {...props} isError>{testContent}</CollapsibleFormWidget>),
shallow(<CollapsibleFormWidget {...props} isError>{testContent}</CollapsibleFormWidget>).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { actions, selectors } from '../../../../../../data/redux';
import { formatMessage } from '../../../../../../../testUtils';
@@ -31,7 +31,7 @@ describe('DurationWidget', () => {
describe('render', () => {
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<DurationWidget {...props} />),
shallow(<DurationWidget {...props} />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -162,4 +162,4 @@ exports[`HandoutWidget snapshots snapshots: renders as expected with handout 1`]
</injectIntl(ShimmedIntlComponent)>
`;
exports[`HandoutWidget snapshots snapshots: renders as expected with isLibrary true 1`] = `""`;
exports[`HandoutWidget snapshots snapshots: renders as expected with isLibrary true 1`] = `null`;

View File

@@ -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';
@@ -44,17 +44,17 @@ describe('HandoutWidget', () => {
describe('snapshots', () => {
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<HandoutWidget {...props} />),
shallow(<HandoutWidget {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with isLibrary true', () => {
expect(
shallow(<HandoutWidget {...props} isLibrary />),
shallow(<HandoutWidget {...props} isLibrary />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with handout', () => {
expect(
shallow(<HandoutWidget {...props} handout="sOMeUrl " />),
shallow(<HandoutWidget {...props} handout="sOMeUrl " />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { LicenseBlurb } from './LicenseBlurb';
@@ -12,32 +12,32 @@ describe('LicenseBlurb', () => {
describe('snapshots', () => {
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<LicenseBlurb {...props} />),
shallow(<LicenseBlurb {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with license equal to Creative Commons', () => {
expect(
shallow(<LicenseBlurb {...props} license="creative-commons" />),
shallow(<LicenseBlurb {...props} license="creative-commons" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected when details.attribution equal true', () => {
expect(
shallow(<LicenseBlurb {...props} license="creative-commons" details={{ attribution: true }} />),
shallow(<LicenseBlurb {...props} license="creative-commons" details={{ attribution: true }} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected when details.attribution and details.noncommercial equal true', () => {
expect(
shallow(<LicenseBlurb {...props} license="creative-commons" details={{ attribution: true, noncommercial: true }} />),
shallow(<LicenseBlurb {...props} license="creative-commons" details={{ attribution: true, noncommercial: true }} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected when details.attribution and details.noDerivatives equal true', () => {
expect(
shallow(<LicenseBlurb {...props} license="creative-commons" details={{ attribution: true, noDerivatives: true }} />),
shallow(<LicenseBlurb {...props} license="creative-commons" details={{ attribution: true, noDerivatives: true }} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected when details.attribution and details.shareAlike equal true', () => {
expect(
shallow(<LicenseBlurb {...props} license="creative-commons" details={{ attribution: true, shareAlike: true }} />),
shallow(<LicenseBlurb {...props} license="creative-commons" details={{ attribution: true, shareAlike: true }} />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { actions } from '../../../../../../data/redux';
import { LicenseDetails, mapStateToProps, mapDispatchToProps } from './LicenseDetails';
@@ -21,6 +21,18 @@ jest.mock('../../../../../../data/redux', () => ({
},
}));
jest.mock('@edx/paragon', () => ({
...jest.requireActual('@edx/paragon'),
CheckboxControl: 'CheckboxControl',
Stack: 'Stack',
Icon: 'Icon',
Form: {
Group: 'Form.Group',
Label: 'Form.Label',
},
ActionRow: { Spacer: 'ActionRow.Spacer' },
}));
describe('LicenseDetails', () => {
const props = {
license: null,
@@ -32,27 +44,27 @@ describe('LicenseDetails', () => {
describe('snapshots', () => {
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<LicenseDetails {...props} />),
shallow(<LicenseDetails {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with level set to library', () => {
expect(
shallow(<LicenseDetails {...props} level="library" />),
shallow(<LicenseDetails {...props} level="library" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with level set to block and license set to select', () => {
expect(
shallow(<LicenseDetails {...props} level="block" license="select" />),
shallow(<LicenseDetails {...props} level="block" license="select" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with level set to block and license set to all rights reserved', () => {
expect(
shallow(<LicenseDetails {...props} level="block" license="all-rights-reserved" />),
shallow(<LicenseDetails {...props} level="block" license="all-rights-reserved" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with level set to block and license set to Creative Commons', () => {
expect(
shallow(<LicenseDetails {...props} level="block" license="creative-commons" />),
shallow(<LicenseDetails {...props} level="block" license="creative-commons" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -1,5 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { shallow } from '@edx/react-unit-test-utils';
import { LicenseDisplay } from './LicenseDisplay';
@@ -19,27 +19,27 @@ describe('LicenseDisplay', () => {
describe('snapshots', () => {
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<LicenseDisplay {...props} />),
shallow(<LicenseDisplay {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with level set to library', () => {
expect(
shallow(<LicenseDisplay {...props} level="library" />),
shallow(<LicenseDisplay {...props} level="library" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with level set to block', () => {
expect(
shallow(<LicenseDisplay {...props} level="block" />),
shallow(<LicenseDisplay {...props} level="block" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with level set to block and license set to select', () => {
expect(
shallow(<LicenseDisplay {...props} level="block" license="select" />),
shallow(<LicenseDisplay {...props} level="block" license="select" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with level set to block and license set to Creative Commons', () => {
expect(
shallow(<LicenseDisplay {...props} level="block" license="creative-commons" />),
shallow(<LicenseDisplay {...props} level="block" license="creative-commons" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -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';
@@ -47,22 +47,22 @@ describe('LicenseSelector', () => {
describe('snapshots', () => {
test('snapshots: renders as expected with default props', () => {
expect(
shallow(<LicenseSelector {...props} />),
shallow(<LicenseSelector {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with library level', () => {
expect(
shallow(<LicenseSelector {...props} level="library" />),
shallow(<LicenseSelector {...props} level="library" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with block level', () => {
expect(
shallow(<LicenseSelector {...props} level="block" />),
shallow(<LicenseSelector {...props} level="block" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with no license', () => {
expect(
shallow(<LicenseSelector {...props} license="" />),
shallow(<LicenseSelector {...props} license="" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`LicenseDetails snapshots snapshots: renders as expected with default props 1`] = `""`;
exports[`LicenseDetails snapshots snapshots: renders as expected with default props 1`] = `null`;
exports[`LicenseDetails snapshots snapshots: renders as expected with level set to block and license set to Creative Commons 1`] = `
<div
@@ -25,7 +25,7 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
className="border-primary-100 border-bottom pb-4"
>
<Form.Group>
<ActionRow>
<[object Object]>
<Icon
className="text-primary-500"
/>
@@ -39,12 +39,12 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
/>
</Form.Label>
<ActionRow.Spacer />
<Component
<CheckboxControl
aria-label="Checkbox"
checked={true}
disabled={true}
/>
</ActionRow>
</[object Object]>
</Form.Group>
<div>
<FormattedMessage
@@ -58,7 +58,7 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
className="border-primary-100 border-bottom pb-4"
>
<Form.Group>
<ActionRow>
<[object Object]>
<Icon />
<Form.Label
className="my-0 text-primary-500"
@@ -70,12 +70,12 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
/>
</Form.Label>
<ActionRow.Spacer />
<Component
<CheckboxControl
aria-label="Checkbox"
disabled={false}
onChange={[Function]}
/>
</ActionRow>
</[object Object]>
</Form.Group>
<div>
<FormattedMessage
@@ -89,7 +89,7 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
className="border-primary-100 border-bottom pb-4"
>
<Form.Group>
<ActionRow>
<[object Object]>
<Icon />
<Form.Label
className="my-0 text-primary-500"
@@ -101,12 +101,12 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
/>
</Form.Label>
<ActionRow.Spacer />
<Component
<CheckboxControl
aria-label="Checkbox"
disabled={false}
onChange={[Function]}
/>
</ActionRow>
</[object Object]>
</Form.Group>
<div>
<FormattedMessage
@@ -118,7 +118,7 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
</div>
<div>
<Form.Group>
<ActionRow>
<[object Object]>
<Icon />
<Form.Label
className="my-0 text-primary-500"
@@ -130,12 +130,12 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
/>
</Form.Label>
<ActionRow.Spacer />
<Component
<CheckboxControl
aria-label="Checkbox"
disabled={false}
onChange={[Function]}
/>
</ActionRow>
</[object Object]>
</Form.Group>
<div>
<FormattedMessage
@@ -179,7 +179,7 @@ exports[`LicenseDetails snapshots snapshots: renders as expected with level set
</div>
`;
exports[`LicenseDetails snapshots snapshots: renders as expected with level set to block and license set to select 1`] = `""`;
exports[`LicenseDetails snapshots snapshots: renders as expected with level set to block and license set to select 1`] = `null`;
exports[`LicenseDetails snapshots snapshots: renders as expected with level set to library 1`] = `
<div

View File

@@ -120,7 +120,7 @@ exports[`LicenseDisplay snapshots snapshots: renders as expected with level set
</Stack>
`;
exports[`LicenseDisplay snapshots snapshots: renders as expected with level set to block and license set to select 1`] = `""`;
exports[`LicenseDisplay snapshots snapshots: renders as expected with level set to block and license set to select 1`] = `null`;
exports[`LicenseDisplay snapshots snapshots: renders as expected with level set to library 1`] = `
<Stack

View File

@@ -27,19 +27,21 @@ exports[`LicenseSelector snapshots snapshots: renders as expected with block lev
Creative Commons
</option>
</Form.Control>
<ActionRow.Spacer />
<IconButtonWithTooltip
iconAs="Icon"
onClick={[Function]}
tooltipContent={
<FormattedMessage
defaultMessage="Clear and apply the course-level license"
description="Message presented to user for action to delete license selection"
id="authoring.videoeditor.license.deleteLicenseSelection"
/>
}
tooltipPlacement="top"
/>
<Fragment>
<ActionRow.Spacer />
<IconButtonWithTooltip
iconAs="Icon"
onClick={[Function]}
tooltipContent={
<FormattedMessage
defaultMessage="Clear and apply the course-level license"
description="Message presented to user for action to delete license selection"
id="authoring.videoeditor.license.deleteLicenseSelection"
/>
}
tooltipPlacement="top"
/>
</Fragment>
</ActionRow>
<div
className="x-small mt-3"
@@ -126,19 +128,21 @@ exports[`LicenseSelector snapshots snapshots: renders as expected with library l
Creative Commons
</option>
</Form.Control>
<ActionRow.Spacer />
<IconButtonWithTooltip
iconAs="Icon"
onClick={[Function]}
tooltipContent={
<FormattedMessage
defaultMessage="Clear and apply the course-level license"
description="Message presented to user for action to delete license selection"
id="authoring.videoeditor.license.deleteLicenseSelection"
/>
}
tooltipPlacement="top"
/>
<Fragment>
<ActionRow.Spacer />
<IconButtonWithTooltip
iconAs="Icon"
onClick={[Function]}
tooltipContent={
<FormattedMessage
defaultMessage="Clear and apply the course-level license"
description="Message presented to user for action to delete license selection"
id="authoring.videoeditor.license.deleteLicenseSelection"
/>
}
tooltipPlacement="top"
/>
</Fragment>
</ActionRow>
<div
className="x-small mt-3"

View File

@@ -24,41 +24,45 @@ exports[`LicenseWidget snapshots snapshots: renders as expected with default pro
<Stack
gap={4}
>
<injectIntl(ShimmedIntlComponent)
level="course"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
level="course"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
license="all-rights-reserved"
licenseDescription={
<FormattedMessage
defaultMessage="Licenses set at the course level appear at the bottom of courseware pages within your course."
description="Message explaining where course level licenses are set"
id="authoring.videoeditor.license.courseLicenseDescription.message"
/>
}
/>
<div
className="border-primary-100 border-bottom my-2"
/>
<Button
className="text-primary-500 font-weight-bold justify-content-start pl-0"
onClick={[Function]}
size="sm"
variant="link"
>
<FormattedMessage
defaultMessage="Add a license for this video"
description="Label for add license button"
id="authoring.videoeditor.license.add.label"
<Fragment>
<injectIntl(ShimmedIntlComponent)
level="course"
license="all-rights-reserved"
/>
</Button>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
level="course"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
license="all-rights-reserved"
licenseDescription={
<FormattedMessage
defaultMessage="Licenses set at the course level appear at the bottom of courseware pages within your course."
description="Message explaining where course level licenses are set"
id="authoring.videoeditor.license.courseLicenseDescription.message"
/>
}
/>
</Fragment>
<Fragment>
<div
className="border-primary-100 border-bottom my-2"
/>
<Button
className="text-primary-500 font-weight-bold justify-content-start pl-0"
onClick={[Function]}
size="sm"
variant="link"
>
<FormattedMessage
defaultMessage="Add a license for this video"
description="Label for add license button"
id="authoring.videoeditor.license.add.label"
/>
</Button>
</Fragment>
</Stack>
</injectIntl(ShimmedIntlComponent)>
`;
@@ -87,26 +91,28 @@ exports[`LicenseWidget snapshots snapshots: renders as expected with isLibrary t
<Stack
gap={4}
>
<injectIntl(ShimmedIntlComponent)
level="library"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
level="library"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
license="all-rights-reserved"
licenseDescription={
<FormattedMessage
defaultMessage="Licenses set at the library level appear at the specific library video."
description="Message explaining where library level licenses are set"
id="authoring.videoeditor.license.libraryLicenseDescription.message"
/>
}
/>
<Fragment>
<injectIntl(ShimmedIntlComponent)
level="library"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
level="library"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
license="all-rights-reserved"
licenseDescription={
<FormattedMessage
defaultMessage="Licenses set at the library level appear at the specific library video."
description="Message explaining where library level licenses are set"
id="authoring.videoeditor.license.libraryLicenseDescription.message"
/>
}
/>
</Fragment>
</Stack>
</injectIntl(ShimmedIntlComponent)>
`;
@@ -135,26 +141,28 @@ exports[`LicenseWidget snapshots snapshots: renders as expected with licenseType
<Stack
gap={4}
>
<injectIntl(ShimmedIntlComponent)
level="block"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
level="block"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
license="all-rights-reserved"
licenseDescription={
<FormattedMessage
defaultMessage="When a video has a different license than the course as a whole, learners see the license at the bottom right of the video player."
description="Message explaining where video specific licenses are seen by users"
id="authoring.videoeditor.license.defaultLicenseDescription.message"
/>
}
/>
<Fragment>
<injectIntl(ShimmedIntlComponent)
level="block"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
level="block"
license="all-rights-reserved"
/>
<injectIntl(ShimmedIntlComponent)
details={Object {}}
license="all-rights-reserved"
licenseDescription={
<FormattedMessage
defaultMessage="When a video has a different license than the course as a whole, learners see the license at the bottom right of the video player."
description="Message explaining where video specific licenses are seen by users"
id="authoring.videoeditor.license.defaultLicenseDescription.message"
/>
}
/>
</Fragment>
</Stack>
</injectIntl(ShimmedIntlComponent)>
`;

View File

@@ -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(<LicenseWidget {...props} />),
shallow(<LicenseWidget {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with isLibrary true', () => {
expect(
shallow(<LicenseWidget {...props} isLibrary licenseType="all-rights-reserved" />),
shallow(<LicenseWidget {...props} isLibrary licenseType="all-rights-reserved" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with licenseType defined', () => {
expect(
shallow(<LicenseWidget {...props} licenseType="all-rights-reserved" />),
shallow(<LicenseWidget {...props} licenseType="all-rights-reserved" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -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`] = `
<injectIntl(ShimmedIntlComponent)

View File

@@ -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';
@@ -53,19 +53,19 @@ describe('SocialShareWidget', () => {
describe('with default props', () => {
it('should return null', () => {
const wrapper = shallow(<SocialShareWidget {...props} />);
expect(wrapper).toMatchSnapshot();
expect(wrapper.snapshot).toMatchSnapshot();
});
});
describe('with videoSharingEnabledForAll false and isLibrary true', () => {
it('should return null', () => {
const wrapper = shallow(<SocialShareWidget {...props} isLibrary />);
expect(wrapper).toMatchSnapshot();
expect(wrapper.snapshot).toMatchSnapshot();
});
});
describe('with videoSharingEnabledForCourse and isLibrary false and videoSharingEnabledForAll true', () => {
it('should return null', () => {
const wrapper = shallow(<SocialShareWidget {...props} videoSharingEnabledForAll />);
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');
});
});

View File

@@ -268,4 +268,4 @@ exports[`ThumbnailWidget snapshots snapshots: renders as expected with default p
</injectIntl(ShimmedIntlComponent)>
`;
exports[`ThumbnailWidget snapshots snapshots: renders as expected with isLibrary true 1`] = `""`;
exports[`ThumbnailWidget snapshots snapshots: renders as expected with isLibrary true 1`] = `null`;

View File

@@ -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(<ThumbnailWidget {...props} />),
shallow(<ThumbnailWidget {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with isLibrary true', () => {
expect(
shallow(<ThumbnailWidget {...props} isLibrary />),
shallow(<ThumbnailWidget {...props} isLibrary />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with a thumbnail provided', () => {
expect(
shallow(<ThumbnailWidget {...props} thumbnail="sOMeUrl" videoId="sOMeViDEoID" />),
shallow(<ThumbnailWidget {...props} thumbnail="sOMeUrl" videoId="sOMeViDEoID" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected where thumbnail uploads are allowed', () => {
expect(
shallow(<ThumbnailWidget {...props} thumbnail="sOMeUrl" allowThumbnailUpload />),
shallow(<ThumbnailWidget {...props} thumbnail="sOMeUrl" allowThumbnailUpload />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected where videoId is valid', () => {
expect(
shallow(<ThumbnailWidget {...props} thumbnail="sOMeUrl" allowThumbnailUpload videoId="sOMeViDEoID" />),
shallow(<ThumbnailWidget {...props} thumbnail="sOMeUrl" allowThumbnailUpload videoId="sOMeViDEoID" />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected where videoId is valid and no thumbnail', () => {
expect(
shallow(<ThumbnailWidget {...props} allowThumbnailUpload videoId="sOMeViDEoID" />),
shallow(<ThumbnailWidget {...props} allowThumbnailUpload videoId="sOMeViDEoID" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -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(<module.ImportTranscriptCard {...props} />),
shallow(<module.ImportTranscriptCard {...props} />).snapshot,
).toMatchSnapshot();
});
});
@@ -36,12 +36,12 @@ describe('ImportTranscriptCard', () => {
el = shallow(<module.ImportTranscriptCard {...props} />);
});
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', () => {

View File

@@ -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(<LanguageSelector {...props} />),
shallow(<LanguageSelector {...props} />).snapshot,
).toMatchSnapshot();
});
});
describe('snapshots -- no', () => {
test('transcripts no Open Languages, all should be disabled', () => {
expect(
shallow(<LanguageSelector {...props} openLanguages={[]} />),
shallow(<LanguageSelector {...props} openLanguages={[]} />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -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(<module.Transcript {...props} />),
shallow(<module.Transcript {...props} />).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(<module.Transcript {...props} language="" />),
shallow(<module.Transcript {...props} language="" />).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(<module.Transcript {...props} />),
shallow(<module.Transcript {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with transcriptUrl', () => {
@@ -87,7 +87,7 @@ describe('Transcript Component', () => {
cancelDelete: jest.fn().mockName('cancelDelete'),
}));
expect(
shallow(<module.Transcript {...props} transcriptUrl="url" />),
shallow(<module.Transcript {...props} transcriptUrl="url" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -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(<module.TranscriptActionMenu {...props} />),
shallow(<module.TranscriptActionMenu {...props} />).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(<module.TranscriptActionMenu {...props} transcriptUrl="url" />),
shallow(<module.TranscriptActionMenu {...props} transcriptUrl="url" />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -393,14 +393,16 @@ exports[`TranscriptWidget component snapshots snapshots: renders as expected wit
<Stack
gap={3}
>
<FormattedMessage
defaultMessage="Add video transcripts (.srt files only) for improved accessibility."
description="Message for adding first transcript"
id="authoring.videoeditor.transcripts.upload.firstTranscriptMessage"
/>
<injectIntl(ShimmedIntlComponent)
setOpen={[Function]}
/>
<Fragment>
<FormattedMessage
defaultMessage="Add video transcripts (.srt files only) for improved accessibility."
description="Message for adding first transcript"
id="authoring.videoeditor.transcripts.upload.firstTranscriptMessage"
/>
<injectIntl(ShimmedIntlComponent)
setOpen={[Function]}
/>
</Fragment>
<div
className="mt-2"
>
@@ -453,11 +455,13 @@ exports[`TranscriptWidget component snapshots snapshots: renders as expected wit
<Stack
gap={3}
>
<FormattedMessage
defaultMessage="Add video transcripts (.srt files only) for improved accessibility."
description="Message for adding first transcript"
id="authoring.videoeditor.transcripts.upload.firstTranscriptMessage"
/>
<Fragment>
<FormattedMessage
defaultMessage="Add video transcripts (.srt files only) for improved accessibility."
description="Message for adding first transcript"
id="authoring.videoeditor.transcripts.upload.firstTranscriptMessage"
/>
</Fragment>
<div
className="mt-2"
>
@@ -629,11 +633,13 @@ exports[`TranscriptWidget component snapshots snapshots: renders as expected wit
<Stack
gap={3}
>
<FormattedMessage
defaultMessage="Add video transcripts (.srt files only) for improved accessibility."
description="Message for adding first transcript"
id="authoring.videoeditor.transcripts.upload.firstTranscriptMessage"
/>
<Fragment>
<FormattedMessage
defaultMessage="Add video transcripts (.srt files only) for improved accessibility."
description="Message for adding first transcript"
id="authoring.videoeditor.transcripts.upload.firstTranscriptMessage"
/>
</Fragment>
<div
className="mt-2"
>

View File

@@ -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(<module.TranscriptWidget {...props} />),
shallow(<module.TranscriptWidget {...props} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with allowTranscriptImport true', () => {
expect(
shallow(<module.TranscriptWidget {...props} allowTranscriptImport />),
shallow(<module.TranscriptWidget {...props} allowTranscriptImport />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with transcripts', () => {
expect(
shallow(<module.TranscriptWidget {...props} transcripts={['en']} />),
shallow(<module.TranscriptWidget {...props} transcripts={['en']} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with transcript urls', () => {
expect(
shallow(<module.TranscriptWidget {...props} selectedVideoTranscriptUrls={{ en: 'url' }} />),
shallow(<module.TranscriptWidget {...props} selectedVideoTranscriptUrls={{ en: 'url' }} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with transcripts and urls', () => {
expect(
shallow(<module.TranscriptWidget {...props} transcripts={['es']} selectedVideoTranscriptUrls={{ en: 'url' }} />),
shallow(<module.TranscriptWidget {...props} transcripts={['es']} selectedVideoTranscriptUrls={{ en: 'url' }} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with allowTranscriptDownloads true', () => {
expect(
shallow(<module.TranscriptWidget {...props} allowTranscriptDownloads transcripts={['en']} />),
shallow(<module.TranscriptWidget {...props} allowTranscriptDownloads transcripts={['en']} />).snapshot,
).toMatchSnapshot();
});
test('snapshots: renders as expected with showTranscriptByDefault true', () => {
expect(
shallow(<module.TranscriptWidget {...props} showTranscriptByDefault transcripts={['en']} />),
shallow(<module.TranscriptWidget {...props} showTranscriptByDefault transcripts={['en']} />).snapshot,
).toMatchSnapshot();
});
test('snapshot: renders ErrorAlert with upload error message', () => {
expect(
shallow(<module.TranscriptWidget {...props} isUploadError transcripts={['en', 'fr']} />),
shallow(<module.TranscriptWidget {...props} isUploadError transcripts={['en', 'fr']} />).snapshot,
).toMatchSnapshot();
});
test('snapshot: renders ErrorAlert with delete error message', () => {
expect(
shallow(<module.TranscriptWidget {...props} isDeleteError transcripts={['en']} />),
shallow(<module.TranscriptWidget {...props} isDeleteError transcripts={['en']} />).snapshot,
).toMatchSnapshot();
});
});

View File

@@ -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(<VideoSourceWidget {...props} />),
shallow(<VideoSourceWidget {...props} />).snapshot,
).toMatchSnapshot();
});
it('videoSharingEnabledForCourse=true', () => {
const newProps = { ...props, videoSharingEnabledForCourse: true };
expect(
shallow(<VideoSourceWidget {...newProps} />),
shallow(<VideoSourceWidget {...newProps} />).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', '');
});

View File

@@ -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(<VideoEditor {...props} />)).toMatchSnapshot();
expect(shallow(<VideoEditor {...props} />).snapshot).toMatchSnapshot();
});
test('renders as expected with default behavior', () => {
expect(shallow(<VideoEditor {...props} studioViewFinished />)).toMatchSnapshot();
expect(shallow(<VideoEditor {...props} studioViewFinished />).snapshot).toMatchSnapshot();
});
});
describe('mapStateToProps', () => {

View File

@@ -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(<BaseModal {...props} />)).toMatchSnapshot();
expect(shallow(<BaseModal {...props} />).snapshot).toMatchSnapshot();
});
});

View File

@@ -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(<module.CodeEditor {...props} />)).toMatchSnapshot();
expect(shallow(<module.CodeEditor {...props} />).snapshot).toMatchSnapshot();
expect(hooks.createCodeMirrorDomNode).toHaveBeenCalled();
});
});

View File

@@ -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(<ErrorAlert {...props}> <p> An Error Message </p> </ErrorAlert>)).toMatchSnapshot();
expect(shallow(<ErrorAlert {...props}> <p> An Error Message </p> </ErrorAlert>).snapshot).toMatchSnapshot();
});
test('snapshot: Loads children and component when error (ErrorAlert)', () => {
expect(shallow(<ErrorAlert {...props} isError hideHeading={false}>{msg}</ErrorAlert>)).toMatchSnapshot();
expect(
shallow(<ErrorAlert {...props} isError hideHeading={false}>{msg}</ErrorAlert>).snapshot,
).toMatchSnapshot();
});
test('snapshot: Does not load heading when hideHeading is true', () => {
expect(shallow(<ErrorAlert {...props} isError hideHeading>{msg}</ErrorAlert>)).toMatchSnapshot();
expect(shallow(<ErrorAlert {...props} isError hideHeading>{msg}</ErrorAlert>).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<FetchErrorAlert isFetchError />)).toMatchSnapshot();
expect(shallow(<FetchErrorAlert isFetchError />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<UploadErrorAlert isUploadError />)).toMatchSnapshot();
expect(shallow(<UploadErrorAlert isUploadError />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -31,4 +31,4 @@ exports[`ErrorAlert component Component Snapshots snapshot: Loads children and c
</Alert>
`;
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`;

View File

@@ -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(<ErrorPage {...emptyProps} />);
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(<ErrorPage {...passedProps} />);
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(<ErrorPage {...passedProps} unitData={unitData} />);
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');
});
});

View File

@@ -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', () => {
<div>Yay</div>
</ErrorBoundary>
);
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', () => {
<ExplodingComponent />
</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');
});
});

View File

@@ -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(<ExpandableTextArea {...props} />)).toMatchSnapshot();
expect(shallow(<ExpandableTextArea {...props} />).snapshot).toMatchSnapshot();
});
test('renders error message', () => {
const wrapper = shallow(<ExpandableTextArea {...props} error errorMessage="eRRormeSsaGE" />);
expect(wrapper).toMatchSnapshot();
expect(wrapper.snapshot).toMatchSnapshot();
});
});
});

View File

@@ -1,20 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`FileInput component snapshot 1`] = `
<FileInput
acceptedFiles=".srt"
fileInput={
Object {
"addFile": [MockFunction props.fileInput.addFile],
"ref": [Function],
}
}
>
<div>
<input
accept=".srt"
className="upload d-none"
onChange={[MockFunction props.fileInput.addFile]}
class="upload d-none"
type="file"
/>
</FileInput>
</div>
`;

View File

@@ -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(<FileInput {...props} />);
el = render(<FileInput {...props} />);
});
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'));
});
});

View File

@@ -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(<AltTextControls {...props} />)).toMatchSnapshot();
expect(shallow(<AltTextControls {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: isDecorative=true errorProps.showAltTextSubmissionError=false', () => {
props.validation.show = false;
expect(shallow(<AltTextControls {...props} />)).toMatchSnapshot();
expect(shallow(<AltTextControls {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<DimensionControls {...props} />)).toMatchSnapshot();
expect(shallow(<DimensionControls {...props} />).snapshot).toMatchSnapshot();
});
test('null value: empty snapshot', () => {
const el = shallow(<DimensionControls {...props} value={null} />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
expect(el.isEmptyRender()).toEqual(true);
});
test('unlocked dimensions', () => {
const el = shallow(<DimensionControls {...props} isLocked={false} />);
expect(el).toMatchSnapshot();
expect(el.snapshot).toMatchSnapshot();
});
});
describe('component tests for dimensions', () => {

View File

@@ -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`] = `
<Form.Group>

View File

@@ -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(<ImageSettingsModal {...props} />)).toMatchSnapshot();
expect(shallow(<ImageSettingsModal {...props} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<SelectImageModal {...props} />);
});
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);
});
});
});

View File

@@ -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(<ImageUploadModal {...props} />)).toMatchSnapshot();
expect(shallow(<ImageUploadModal {...props} />).snapshot).toMatchSnapshot();
});
test('snapshot: selection has no externalUrl (Select Image Modal)', () => {
expect(shallow(<ImageUploadModal {...props} selection={null} />)).toMatchSnapshot();
expect(shallow(<ImageUploadModal {...props} selection={null} />).snapshot).toMatchSnapshot();
});
test('snapshot: no selection (Select Image Modal)', () => {
expect(shallow(<ImageUploadModal {...props} selection={null} />)).toMatchSnapshot();
expect(shallow(<ImageUploadModal {...props} selection={null} />).snapshot).toMatchSnapshot();
});
});
});

View File

@@ -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(<RawEditor {...defaultProps} />)).toMatchSnapshot();
expect(shallow(<RawEditor {...defaultProps} />).snapshot).toMatchSnapshot();
});
test('renders as expected with lang equal to xml', () => {
expect(shallow(<RawEditor {...xmlProps} />)).toMatchSnapshot();
expect(shallow(<RawEditor {...xmlProps} />).snapshot).toMatchSnapshot();
});
test('renders as expected with content equal to null', () => {
expect(shallow(<RawEditor {...noContentProps} />)).toMatchSnapshot();
expect(shallow(<RawEditor {...noContentProps} />).snapshot).toMatchSnapshot();
});
});

View File

@@ -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(<IntlProvider locale="en">{component}</IntlProvider>);
test('snapshot: not loaded, show spinner', () => {
expect(shallowWithIntl(<Gallery {...props} isLoaded={false} />)).toMatchSnapshot();
expect(shallowWithIntl(<Gallery {...props} isLoaded={false} />).snapshot).toMatchSnapshot();
});
test('snapshot: loaded but no images, show empty gallery', () => {
expect(shallowWithIntl(<Gallery {...props} galleryIsEmpty />)).toMatchSnapshot();
expect(shallowWithIntl(<Gallery {...props} galleryIsEmpty />).snapshot).toMatchSnapshot();
});
test('snapshot: loaded but search returns no images, show 0 search result gallery', () => {
expect(shallowWithIntl(<Gallery {...props} searchIsEmpty />)).toMatchSnapshot();
expect(shallowWithIntl(<Gallery {...props} searchIsEmpty />).snapshot).toMatchSnapshot();
});
test('snapshot: loaded, show gallery', () => {
expect(shallowWithIntl(<Gallery {...props} />)).toMatchSnapshot();
expect(shallowWithIntl(<Gallery {...props} />).snapshot).toMatchSnapshot();
});
});
});

Some files were not shown because too many files have changed in this diff Show More