refactor(tests): enzyme => react-testing-library (#37712)

* refactor: 💡 rewrite enzyme tests in react-testing-library

* fix: 🐛 remove enzyme imports from frame-runner.js

* chore: 🤖 install and add enzyme imports to frame-runner.js back
This commit is contained in:
Abdelrahman Ashraf
2019-11-08 13:20:25 +02:00
committed by mrugesh
parent 5ae8470bd5
commit 94532f98db
17 changed files with 1109 additions and 1242 deletions

249
client/package-lock.json generated
View File

@ -2030,9 +2030,9 @@
"integrity": "sha512-ONhaKPIufzzrlNbqtWFFd+jlnemX6lJAgq9ZeiZtS7I1PIf/la7CW4m83rTXRnVnsMbW2k56pGYu7AUFJD9Pow=="
},
"@testing-library/dom": {
"version": "6.8.1",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-6.8.1.tgz",
"integrity": "sha512-b+Q4wryafqsSTFBV14cc5xqhN/OVB9oMeUQvZwy1kVx+kdqs4zQAcyvCsFkdcqx7NxibWpUN/fBIUaqyAEhitw==",
"version": "6.10.1",
"resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-6.10.1.tgz",
"integrity": "sha512-5BPKxaO+zSJDUbVZBRNf9KrmDkm/EcjjaHSg3F9+031VZyPACKXlwLBjVzZxheunT9m72DoIq7WvyE457/Xweg==",
"dev": true,
"requires": {
"@babel/runtime": "^7.6.2",
@ -2044,9 +2044,9 @@
},
"dependencies": {
"@babel/runtime": {
"version": "7.6.3",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.6.3.tgz",
"integrity": "sha512-kq6anf9JGjW8Nt5rYfEuGRaEAaH1mkv3Bbu6rYvLOpPh/RusSJXuKPEAoZ7L7gybZkchE8+NV5g9vKF4AGAtsA==",
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.2.tgz",
"integrity": "sha512-JONRbXbTXc9WQE2mAZd1p0Z3DZ/6vaQIkgYMSTP3KjRCyd7rCZCcfhCyX+YjwcKxcZ82UrxbRD358bpExNgrjw==",
"dev": true,
"requires": {
"regenerator-runtime": "^0.13.2"
@ -2097,9 +2097,9 @@
}
},
"react-is": {
"version": "16.10.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.2.tgz",
"integrity": "sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA==",
"version": "16.11.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz",
"integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw==",
"dev": true
},
"regenerator-runtime": {
@ -2170,9 +2170,9 @@
}
},
"@testing-library/react": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-9.3.0.tgz",
"integrity": "sha512-FTPCwmLo0tLtP50Au2uGz4/N1BcJTnBx4StDVHZ47zPMEj1/+J2rk/RTj8SLoHRKWCtcmhN4wRmudOXQNP29/w==",
"version": "9.3.2",
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-9.3.2.tgz",
"integrity": "sha512-J6ftWtm218tOLS175MF9eWCxGp+X+cUXCpkPIin8KAXWtyZbr9CbqJ8M8QNd6spZxJDAGlw+leLG4MJWLlqVgg==",
"dev": true,
"requires": {
"@babel/runtime": "^7.6.0",
@ -2181,9 +2181,9 @@
},
"dependencies": {
"@babel/runtime": {
"version": "7.6.3",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.6.3.tgz",
"integrity": "sha512-kq6anf9JGjW8Nt5rYfEuGRaEAaH1mkv3Bbu6rYvLOpPh/RusSJXuKPEAoZ7L7gybZkchE8+NV5g9vKF4AGAtsA==",
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.7.2.tgz",
"integrity": "sha512-JONRbXbTXc9WQE2mAZd1p0Z3DZ/6vaQIkgYMSTP3KjRCyd7rCZCcfhCyX+YjwcKxcZ82UrxbRD358bpExNgrjw==",
"dev": true,
"requires": {
"regenerator-runtime": "^0.13.2"
@ -2365,9 +2365,9 @@
}
},
"@types/react-dom": {
"version": "16.9.2",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.2.tgz",
"integrity": "sha512-hgPbBoI1aTSTvZwo8HYw35UaTldW6n2ETLvHAcfcg1FaOuBV3olmyCe5eMpx2WybWMBPv0MdU2t5GOcQhP+3zA==",
"version": "16.9.4",
"resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.4.tgz",
"integrity": "sha512-fya9xteU/n90tda0s+FtN5Ym4tbgxpq/hb/Af24dvs6uYnYn+fspaxw5USlw0R8apDNwxsqumdRoCoKitckQqw==",
"dev": true,
"requires": {
"@types/react": "*"
@ -2385,9 +2385,9 @@
"integrity": "sha512-78AdXtlhpCHT0K3EytMpn4JNxaf5tbqbLcbIRoQIHzpTIyjpxLQKRoxU55ujBXAtg3Nl2h/XWvfDa9dsMOd0pQ=="
},
"@types/testing-library__dom": {
"version": "6.5.3",
"resolved": "https://registry.npmjs.org/@types/testing-library__dom/-/testing-library__dom-6.5.3.tgz",
"integrity": "sha512-E/LSnbzo25gCLy/YOHKY9KJ+rfI8hy5cfbScyZqVuFw9CUMn1faWEDnxMcVHgjAbWtTStfllB8TwNKCx8bAKeA==",
"version": "6.10.0",
"resolved": "https://registry.npmjs.org/@types/testing-library__dom/-/testing-library__dom-6.10.0.tgz",
"integrity": "sha512-mL/GMlyQxiZplbUuFNwA0vAI3k3uJNSf6slr5AVve9TXmfLfyefNT0uHHnxwdYuPMxYD5gI/+dgAvc/5opW9JQ==",
"dev": true,
"requires": {
"pretty-format": "^24.3.0"
@ -2925,17 +2925,6 @@
"react-is": "^16.9.0"
},
"dependencies": {
"function.prototype.name": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.1.tgz",
"integrity": "sha512-e1NzkiJuw6xqVH7YSdiW/qDHebcmMhPNe6w+4ZYYEg0VA+LaLzx37RimbPLuonHhYGFGPx1ME2nSi74JiaCr/Q==",
"requires": {
"define-properties": "^1.1.3",
"function-bind": "^1.1.1",
"functions-have-names": "^1.1.1",
"is-callable": "^1.1.4"
}
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@ -2955,9 +2944,9 @@
}
},
"react-is": {
"version": "16.10.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.2.tgz",
"integrity": "sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA=="
"version": "16.11.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz",
"integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw=="
}
}
},
@ -3226,9 +3215,9 @@
},
"dependencies": {
"es-abstract": {
"version": "1.15.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.15.0.tgz",
"integrity": "sha512-bhkEqWJ2t2lMeaJDuk7okMkJWI/yqgH/EoGwpcvv0XW9RWQsRspI4wt6xuyuvMvvQE3gg/D9HXppgk21w78GyQ==",
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.0.tgz",
"integrity": "sha512-xdQnfykZ9JMEiasTAJZJdMWCQ1Vm00NBw79/AWi7ELfZuuPCSOMDZbT9mkOfSctVtfhb+sAAzrm+j//GjjLHLg==",
"requires": {
"es-to-primitive": "^1.2.0",
"function-bind": "^1.1.1",
@ -3268,13 +3257,55 @@
}
},
"array.prototype.flat": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.1.tgz",
"integrity": "sha512-rVqIs330nLJvfC7JqYvEWwqVr5QjYF1ib02i3YJtR/fICO6527Tjpc/e4Mvmxh3GIePPreRXMdaGyC99YphWEw==",
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.2.tgz",
"integrity": "sha512-VXjh7lAL4KXKF2hY4FnEW9eRW6IhdvFW1sN/JwLbmECbCgACCnBHNyP3lFiYuttr0jxRN9Bsc5+G27dMseSWqQ==",
"requires": {
"define-properties": "^1.1.2",
"es-abstract": "^1.10.0",
"define-properties": "^1.1.3",
"es-abstract": "^1.15.0",
"function-bind": "^1.1.1"
},
"dependencies": {
"es-abstract": {
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.0.tgz",
"integrity": "sha512-xdQnfykZ9JMEiasTAJZJdMWCQ1Vm00NBw79/AWi7ELfZuuPCSOMDZbT9mkOfSctVtfhb+sAAzrm+j//GjjLHLg==",
"requires": {
"es-to-primitive": "^1.2.0",
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.0",
"is-callable": "^1.1.4",
"is-regex": "^1.0.4",
"object-inspect": "^1.6.0",
"object-keys": "^1.1.1",
"string.prototype.trimleft": "^2.1.0",
"string.prototype.trimright": "^2.1.0"
}
},
"es-to-primitive": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz",
"integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==",
"requires": {
"is-callable": "^1.1.4",
"is-date-object": "^1.0.1",
"is-symbol": "^1.0.2"
}
},
"is-symbol": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz",
"integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==",
"requires": {
"has-symbols": "^1.0.0"
}
},
"object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
}
}
},
"arraybuffer.slice": {
@ -7231,9 +7262,9 @@
}
},
"react-is": {
"version": "16.10.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.2.tgz",
"integrity": "sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA=="
"version": "16.11.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz",
"integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw=="
},
"semver": {
"version": "5.7.1",
@ -7255,17 +7286,6 @@
"semver": "^5.7.0"
},
"dependencies": {
"function.prototype.name": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.1.tgz",
"integrity": "sha512-e1NzkiJuw6xqVH7YSdiW/qDHebcmMhPNe6w+4ZYYEg0VA+LaLzx37RimbPLuonHhYGFGPx1ME2nSi74JiaCr/Q==",
"requires": {
"define-properties": "^1.1.3",
"function-bind": "^1.1.1",
"functions-have-names": "^1.1.1",
"is-callable": "^1.1.4"
}
},
"loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@ -7285,9 +7305,9 @@
}
},
"react-is": {
"version": "16.10.2",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.10.2.tgz",
"integrity": "sha512-INBT1QEgtcCCgvccr5/86CfD71fw9EPmDxgiJX4I2Ddr6ZsV6iFXsuby+qWJPtmNuMY0zByTsG4468P7nHuNWA=="
"version": "16.11.0",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.11.0.tgz",
"integrity": "sha512-gbBVYR2p8mnriqAwWx9LbuUrShnAuSCNnuPGyc7GJrMVQtPDAh8iLpv7FRuMPFb56KkaVZIYSz1PrjI9q0QPCw=="
},
"semver": {
"version": "5.7.1",
@ -9267,13 +9287,14 @@
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
},
"function.prototype.name": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.0.tgz",
"integrity": "sha512-Bs0VRrTz4ghD8pTmbJQD1mZ8A/mN0ur/jGz+A6FBxPDUPkm1tNfF6bhTYPA7i7aF4lZJVr+OXTNNrnnIl58Wfg==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.1.tgz",
"integrity": "sha512-e1NzkiJuw6xqVH7YSdiW/qDHebcmMhPNe6w+4ZYYEg0VA+LaLzx37RimbPLuonHhYGFGPx1ME2nSi74JiaCr/Q==",
"requires": {
"define-properties": "^1.1.2",
"define-properties": "^1.1.3",
"function-bind": "^1.1.1",
"is-callable": "^1.1.3"
"functions-have-names": "^1.1.1",
"is-callable": "^1.1.4"
}
},
"functional-red-black-tree": {
@ -9282,9 +9303,9 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc="
},
"functions-have-names": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.1.1.tgz",
"integrity": "sha512-U0kNHUoxwPNPWOJaMG7Z00d4a/qZVrFtzWJRaK8V9goaVOCXBSQSJpt3MYGNtkScKEBKovxLjnNdC9MlXwo5Pw=="
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.0.tgz",
"integrity": "sha512-zKXyzksTeaCSw5wIX79iCA40YAa6CJMJgNg9wdkU/ERBrIdPSimPICYiLp65lRbSBqtiHql/HZfS2DyI/AH6tQ=="
},
"gatsby": {
"version": "2.16.4",
@ -11678,9 +11699,9 @@
"integrity": "sha512-d4sze1JNC454Wdo2fkuyzCr6aHcbL6PGGuFAz0Li/NcOm1tCHGnWDRmJP85dh9IhQErTc2svWFEX5xHIOo//kQ=="
},
"handlebars": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.3.1.tgz",
"integrity": "sha512-c0HoNHzDiHpBt4Kqe99N8tdLPKAnGCQ73gYMPWtAYM4PwGnf7xl8PBUHJqh9ijlzt2uQKaSRxbXRt+rZ7M2/kA==",
"version": "4.5.1",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.1.tgz",
"integrity": "sha512-C29UoFzHe9yM61lOsIlCE5/mQVGrnIOrOq7maQl76L7tYPCgC1og0Ajt6uWnX4ZTxBPnjw+CUvawphwCfJgUnA==",
"dev": true,
"requires": {
"neo-async": "^2.6.0",
@ -12000,9 +12021,9 @@
"integrity": "sha512-P+M65QY2JQ5Y0G9KKdlDpo0zK+/OHptU5AaBwUfAIDJZk1MYf32Frm84EcOytfJE0t5JvkAnKlmjsXDnWzCJmQ=="
},
"html-element-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/html-element-map/-/html-element-map-1.0.1.tgz",
"integrity": "sha512-BZSfdEm6n706/lBfXKWa4frZRZcT5k1cOusw95ijZsHlI+GdgY0v95h6IzO3iIDf2ROwq570YTwqNPqHcNMozw==",
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/html-element-map/-/html-element-map-1.1.0.tgz",
"integrity": "sha512-iqiG3dTZmy+uUaTmHarTL+3/A2VW9ox/9uasKEZC+R/wAtUrTcRlXPSaPqsnWPfIu8wqn09jQNwMRqzL54jSYA==",
"requires": {
"array-filter": "^1.0.0"
}
@ -16062,9 +16083,9 @@
"integrity": "sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc="
},
"nearley": {
"version": "2.16.0",
"resolved": "https://registry.npmjs.org/nearley/-/nearley-2.16.0.tgz",
"integrity": "sha512-Tr9XD3Vt/EujXbZBv6UAHYoLUSMQAxSsTnm9K3koXzjzNWY195NqALeyrzLZBKzAkL3gl92BcSogqrHjD8QuUg==",
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/nearley/-/nearley-2.19.0.tgz",
"integrity": "sha512-2v52FTw7RPqieZr3Gth1luAXZR7Je6q3KaDHY5bjl/paDUdMu35fZ8ICNgiYJRr3tf3NMvIQQR1r27AvEr9CRA==",
"requires": {
"commander": "^2.19.0",
"moo": "^0.4.3",
@ -21071,13 +21092,55 @@
}
},
"string.prototype.trim": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz",
"integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=",
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.0.tgz",
"integrity": "sha512-9EIjYD/WdlvLpn987+ctkLf0FfvBefOCuiEr2henD8X+7jfwPnyvTdmW8OJhj5p+M0/96mBdynLWkxUr+rHlpg==",
"requires": {
"define-properties": "^1.1.2",
"es-abstract": "^1.5.0",
"function-bind": "^1.0.2"
"define-properties": "^1.1.3",
"es-abstract": "^1.13.0",
"function-bind": "^1.1.1"
},
"dependencies": {
"es-abstract": {
"version": "1.16.0",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.16.0.tgz",
"integrity": "sha512-xdQnfykZ9JMEiasTAJZJdMWCQ1Vm00NBw79/AWi7ELfZuuPCSOMDZbT9mkOfSctVtfhb+sAAzrm+j//GjjLHLg==",
"requires": {
"es-to-primitive": "^1.2.0",
"function-bind": "^1.1.1",
"has": "^1.0.3",
"has-symbols": "^1.0.0",
"is-callable": "^1.1.4",
"is-regex": "^1.0.4",
"object-inspect": "^1.6.0",
"object-keys": "^1.1.1",
"string.prototype.trimleft": "^2.1.0",
"string.prototype.trimright": "^2.1.0"
}
},
"es-to-primitive": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz",
"integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==",
"requires": {
"is-callable": "^1.1.4",
"is-date-object": "^1.0.1",
"is-symbol": "^1.0.2"
}
},
"is-symbol": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz",
"integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==",
"requires": {
"has-symbols": "^1.0.0"
}
},
"object-keys": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz",
"integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA=="
}
}
},
"string.prototype.trimleft": {
@ -21917,20 +21980,20 @@
"integrity": "sha512-uRdSdu1oA1rncCQL7sCj8vSyZkgtL7faaw9Tc9rZ3mGgraQ7+Pdx7w5mnOSF3gw9ZNG6oc+KXfkon3bKuROm0g=="
},
"uglify-js": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.0.tgz",
"integrity": "sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==",
"version": "3.6.8",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.6.8.tgz",
"integrity": "sha512-XhHJ3S3ZyMwP8kY1Gkugqx3CJh2C3O0y8NPiSxtm1tyD/pktLAkFZsFGpuNfTZddKDQ/bbDBLAd2YyA1pbi8HQ==",
"dev": true,
"optional": true,
"requires": {
"commander": "~2.20.0",
"commander": "~2.20.3",
"source-map": "~0.6.1"
},
"dependencies": {
"commander": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz",
"integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==",
"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,
"optional": true
},
@ -22480,9 +22543,9 @@
}
},
"wait-for-expect": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/wait-for-expect/-/wait-for-expect-3.0.0.tgz",
"integrity": "sha512-9LyJL+MugZdcQn5V9PBSEC4d2UPTy1xX2U9wTc6LvG/18qeeYqdE/CgmAQJxc/Vcjs+VzH+wiyIXxz05F3nrpQ==",
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/wait-for-expect/-/wait-for-expect-3.0.1.tgz",
"integrity": "sha512-3Ha7lu+zshEG/CeHdcpmQsZnnZpPj/UsG3DuKO8FskjuDbkx3jE3845H+CuwZjA2YWYDfKMU2KhnCaXMLd3wVw==",
"dev": true
},
"walker": {

View File

@ -95,7 +95,7 @@
},
"devDependencies": {
"@testing-library/jest-dom": "^4.1.2",
"@testing-library/react": "^9.3.0",
"@testing-library/react": "^9.3.2",
"autoprefixer": "^9.6.5",
"babel-plugin-transform-imports": "^1.5.1",
"chokidar": "^2.1.5",

View File

@ -40,11 +40,13 @@ async function initTestFrame(e = {}) {
if (e.loadEnzyme) {
let Adapter16;
/* eslint-disable no-inline-comments */
[{ default: Enzyme }, { default: Adapter16 }] = await Promise.all([
import(/* webpackChunkName: "enzyme" */ 'enzyme'),
import(/* webpackChunkName: "enzyme-adapter" */ 'enzyme-adapter-react-16')
]);
/* eslint-enable no-inline-comments */
Enzyme.configure({ adapter: new Adapter16() });
}

View File

@ -1,9 +1,10 @@
/* global expect jest */
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import Enzyme, { shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { render } from '@testing-library/react';
import { Provider } from 'react-redux';
import { createStore } from '../../redux/createStore';
import { Map } from './';
import mockChallengeNodes from '../../__mocks__/challenge-nodes';
@ -11,8 +12,9 @@ import mockIntroNodes from '../../__mocks__/intro-nodes';
import { dasherize } from '../../../../utils/slugs';
Enzyme.configure({ adapter: new Adapter() });
const renderer = new ShallowRenderer();
function renderWithRedux(ui) {
return render(<Provider store={createStore()}>{ui}</Provider>);
}
const baseProps = {
introNodes: mockIntroNodes,
@ -27,7 +29,7 @@ const baseProps = {
window.scrollTo = jest.fn();
test('<Map /> snapshot', () => {
const componentToRender = (
const { container } = renderWithRedux(
<Map
introNodes={mockIntroNodes}
nodes={mockChallengeNodes}
@ -36,8 +38,8 @@ test('<Map /> snapshot', () => {
toggleSuperBlock={() => {}}
/>
);
const component = renderer.render(componentToRender);
expect(component).toMatchSnapshot('Map');
expect(container).toMatchSnapshot('Map');
});
describe('<Map/>', () => {
@ -61,8 +63,9 @@ describe('<Map/>', () => {
toggleBlock: blockSpy,
toggleSuperBlock: superSpy
};
const mapToRender = <Map {...props} />;
shallow(mapToRender);
renderWithRedux(<Map {...props} />);
expect(blockSpy).toHaveBeenCalledTimes(1);
expect(superSpy).toHaveBeenCalledTimes(1);
expect(initializeSpy).toHaveBeenCalledTimes(1);
@ -80,8 +83,7 @@ describe('<Map/>', () => {
currentChallengeId
};
const mapToRender = <Map {...props} />;
shallow(mapToRender);
renderWithRedux(<Map {...props} />);
expect(blockSpy).toHaveBeenCalledTimes(1);
// the block here should always be the first block of the superblock
@ -102,8 +104,7 @@ describe('<Map/>', () => {
currentChallengeId
};
const mapToRender = <Map {...props} />;
shallow(mapToRender);
renderWithRedux(<Map {...props} />);
expect(blockSpy).toHaveBeenCalledTimes(1);
expect(blockSpy).toHaveBeenCalledWith(idNode.block);
@ -120,8 +121,9 @@ describe('<Map/>', () => {
toggleBlock: blockSpy,
toggleSuperBlock: superSpy
};
const mapToRender = <Map {...props} />;
shallow(mapToRender);
renderWithRedux(<Map {...props} />);
expect(blockSpy).toHaveBeenCalledTimes(1);
expect(blockSpy).toHaveBeenCalledWith(defaultNode.block);
@ -135,8 +137,9 @@ describe('<Map/>', () => {
...baseProps,
resetExpansion: expansionSpy
};
const mapToRender = <Map {...props} />;
shallow(mapToRender);
renderWithRedux(<Map {...props} />);
expect(expansionSpy).toHaveBeenCalledTimes(1);
});
});

View File

@ -1,567 +1,93 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Map /> snapshot: Map 1`] = `
<Row
bsClass="row"
componentClass="div"
>
<Col
bsClass="col"
componentClass="div"
sm={10}
smOffset={1}
xs={12}
<div>
<div
class="row"
>
<div
className="map-ui"
class="col-sm-10 col-sm-offset-1 col-xs-12"
>
<ul>
<Connect(SuperBlock)
introNodes={
Array [
Object {
"fields": Object {
"slug": "/super-block-one/block-a",
},
"frontmatter": Object {
"block": "Block A",
"title": "Introduction to Block A",
},
},
Object {
"fields": Object {
"slug": "/super-block-one/block-b",
},
"frontmatter": Object {
"block": "Block B",
"title": "Introduction to Block B",
},
},
Object {
"fields": Object {
"slug": "/super-block-one/block-c",
},
"frontmatter": Object {
"block": "Block C",
"title": "Introduction to Block C",
},
},
]
}
nodes={
Array [
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-one/block-a/challenge-one",
},
"id": "a",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-one/block-a/challenge-two",
},
"id": "b",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge Two",
},
Object {
"block": "block-b",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-one/block-b/challenge-one",
},
"id": "c",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-b",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-one/block-b/challenge-two",
},
"id": "d",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge Two",
},
Object {
"block": "block-c",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block C",
"slug": "/super-block-one/block-c/challenge-one",
},
"id": "e",
"isPrivate": true,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-two/block-a/challenge-one",
},
"id": "f",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-two/block-a/challenge-two",
},
"id": "g",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge Two",
},
Object {
"block": "block-b",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-two/block-b/challenge-one",
},
"id": "h",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge One",
},
Object {
"block": "block-b",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-two/block-b/challenge-two",
},
"id": "i",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge Two",
},
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-three/block-a/challenge-one",
},
"id": "j",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Three",
"title": "Challenge One",
},
Object {
"block": "block-c",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block C",
"slug": "/super-block-three/block-c/challenge-two",
},
"id": "k",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Three",
"title": "Challenge Two",
},
]
}
superBlock="Super Block One"
/>
<Connect(SuperBlock)
introNodes={
Array [
Object {
"fields": Object {
"slug": "/super-block-one/block-a",
},
"frontmatter": Object {
"block": "Block A",
"title": "Introduction to Block A",
},
},
Object {
"fields": Object {
"slug": "/super-block-one/block-b",
},
"frontmatter": Object {
"block": "Block B",
"title": "Introduction to Block B",
},
},
Object {
"fields": Object {
"slug": "/super-block-one/block-c",
},
"frontmatter": Object {
"block": "Block C",
"title": "Introduction to Block C",
},
},
]
}
nodes={
Array [
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-one/block-a/challenge-one",
},
"id": "a",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-one/block-a/challenge-two",
},
"id": "b",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge Two",
},
Object {
"block": "block-b",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-one/block-b/challenge-one",
},
"id": "c",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-b",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-one/block-b/challenge-two",
},
"id": "d",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge Two",
},
Object {
"block": "block-c",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block C",
"slug": "/super-block-one/block-c/challenge-one",
},
"id": "e",
"isPrivate": true,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-two/block-a/challenge-one",
},
"id": "f",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-two/block-a/challenge-two",
},
"id": "g",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge Two",
},
Object {
"block": "block-b",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-two/block-b/challenge-one",
},
"id": "h",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge One",
},
Object {
"block": "block-b",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-two/block-b/challenge-two",
},
"id": "i",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge Two",
},
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-three/block-a/challenge-one",
},
"id": "j",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Three",
"title": "Challenge One",
},
Object {
"block": "block-c",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block C",
"slug": "/super-block-three/block-c/challenge-two",
},
"id": "k",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Three",
"title": "Challenge Two",
},
]
}
superBlock="Super Block Two"
/>
<Connect(SuperBlock)
introNodes={
Array [
Object {
"fields": Object {
"slug": "/super-block-one/block-a",
},
"frontmatter": Object {
"block": "Block A",
"title": "Introduction to Block A",
},
},
Object {
"fields": Object {
"slug": "/super-block-one/block-b",
},
"frontmatter": Object {
"block": "Block B",
"title": "Introduction to Block B",
},
},
Object {
"fields": Object {
"slug": "/super-block-one/block-c",
},
"frontmatter": Object {
"block": "Block C",
"title": "Introduction to Block C",
},
},
]
}
nodes={
Array [
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-one/block-a/challenge-one",
},
"id": "a",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-one/block-a/challenge-two",
},
"id": "b",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge Two",
},
Object {
"block": "block-b",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-one/block-b/challenge-one",
},
"id": "c",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-b",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-one/block-b/challenge-two",
},
"id": "d",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge Two",
},
Object {
"block": "block-c",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block C",
"slug": "/super-block-one/block-c/challenge-one",
},
"id": "e",
"isPrivate": true,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-two/block-a/challenge-one",
},
"id": "f",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-two/block-a/challenge-two",
},
"id": "g",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge Two",
},
Object {
"block": "block-b",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-two/block-b/challenge-one",
},
"id": "h",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge One",
},
Object {
"block": "block-b",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-two/block-b/challenge-two",
},
"id": "i",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Two",
"title": "Challenge Two",
},
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-three/block-a/challenge-one",
},
"id": "j",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Three",
"title": "Challenge One",
},
Object {
"block": "block-c",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block C",
"slug": "/super-block-three/block-c/challenge-two",
},
"id": "k",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block Three",
"title": "Challenge Two",
},
]
}
superBlock="Super Block Three"
/>
<Spacer />
</ul>
<div
class="map-ui"
>
<ul>
<li
class="superblock "
id="super-block-one"
>
<button
aria-expanded="false"
class="map-title"
>
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</svg>
<h4>
Super Block One Certification (300 hours)
</h4>
</button>
</li>
<li
class="superblock "
id="super-block-two"
>
<button
aria-expanded="false"
class="map-title"
>
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</svg>
<h4>
Super Block Two Certification (300 hours)
</h4>
</button>
</li>
<li
class="superblock "
id="super-block-three"
>
<button
aria-expanded="false"
class="map-title"
>
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</svg>
<h4>
Super Block Three Certification (300 hours)
</h4>
</button>
</li>
<div
class="spacer"
style="padding: 15px 0px; height: 1px;"
/>
</ul>
</div>
</div>
</Col>
</Row>
</div>
</div>
`;

View File

@ -1,61 +1,50 @@
/* global expect */
/* global jest, expect */
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import sinon from 'sinon';
import { render, fireEvent } from '@testing-library/react';
import { Block } from './Block';
import mockChallengeNodes from '../../../__mocks__/challenge-nodes';
import mockIntroNodes from '../../../__mocks__/intro-nodes';
import mockCompleted from '../../../__mocks__/completedChallengesMock';
Enzyme.configure({ adapter: new Adapter() });
const renderer = new ShallowRenderer();
test('<Block /> not expanded snapshot', () => {
const toggleSpy = sinon.spy();
const toggleMapSpy = sinon.spy();
const componentToRender = (
const { container } = render(
<Block
blockDashedName='block-a'
challenges={mockChallengeNodes.filter(node => node.block === 'block-a')}
completedChallenges={mockCompleted}
intro={mockIntroNodes[0]}
isExpanded={false}
toggleBlock={toggleSpy}
toggleMapModal={toggleMapSpy}
toggleBlock={() => {}}
toggleMapModal={() => {}}
/>
);
const component = renderer.render(componentToRender);
expect(component).toMatchSnapshot('block-not-expanded');
expect(container).toMatchSnapshot('block-not-expanded');
});
test('<Block expanded snapshot', () => {
const toggleSpy = sinon.spy();
const toggleMapSpy = sinon.spy();
const componentToRender = (
const { container } = render(
<Block
blockDashedName='block-a'
challenges={mockChallengeNodes.filter(node => node.block === 'block-a')}
completedChallenges={mockCompleted}
intro={mockIntroNodes[0]}
isExpanded={true}
toggleBlock={toggleSpy}
toggleMapModal={toggleMapSpy}
toggleBlock={() => {}}
toggleMapModal={() => {}}
/>
);
const component = renderer.render(componentToRender);
expect(component).toMatchSnapshot('block-expanded');
expect(container).toMatchSnapshot('block-expanded');
});
test('<Block /> should handle toggle clicks correctly', () => {
const toggleSpy = sinon.spy();
const toggleMapSpy = sinon.spy();
test('<Block /> should handle toggle clicks correctly', async () => {
const toggleSpy = jest.fn();
const toggleMapSpy = jest.fn();
const props = {
blockDashedName: 'block-a',
challenges: mockChallengeNodes.filter(node => node.block === 'block-a'),
@ -66,30 +55,21 @@ test('<Block /> should handle toggle clicks correctly', () => {
toggleMapModal: toggleMapSpy
};
const componentToRender = <Block {...props} />;
const { container, rerender } = render(<Block {...props} />);
const enzymeWrapper = Enzyme.shallow(componentToRender);
expect(toggleSpy).not.toHaveBeenCalled();
expect(container.querySelector('.map-title h4')).toHaveTextContent('Block A');
expect(container.querySelector('ul').children.length).toBe(0);
expect(toggleSpy.called).toBe(false);
expect(
enzymeWrapper
.find('.map-title')
.find('h4')
.text()
).toBe('Block A');
fireEvent.click(container.querySelector('.map-title'));
enzymeWrapper.find('.map-title').simulate('click');
expect(toggleSpy).toHaveBeenCalledTimes(1);
expect(toggleSpy).toHaveBeenCalledWith('block-a');
expect(toggleSpy.called).toBe(true);
expect(toggleSpy.calledWithExactly('block-a')).toBe(true);
rerender(<Block {...props} isExpanded={true} />);
enzymeWrapper.setProps({ ...props, isExpanded: true });
expect(
enzymeWrapper
.find('.map-title')
.find('h4')
.text()
).toBe('Block A');
expect(enzymeWrapper.find('ul').length).toBe(1);
expect(container.querySelector('.map-title h4')).toHaveTextContent('Block A');
expect(container.querySelector('ul').children.length).toBe(
props.challenges.length + (props.intro ? 1 : 0)
);
});

View File

@ -1,50 +1,49 @@
/* global expect */
/* global jest, expect */
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import sinon from 'sinon';
import { render, fireEvent } from '@testing-library/react';
import { Provider } from 'react-redux';
import { createStore } from '../../../redux/createStore';
import { SuperBlock } from './SuperBlock';
import mockChallengeNodes from '../../../__mocks__/challenge-nodes';
import mockIntroNodes from '../../../__mocks__/intro-nodes';
Enzyme.configure({ adapter: new Adapter() });
const renderer = new ShallowRenderer();
function renderWithRedux(ui) {
return render(<Provider store={createStore()}>{ui}</Provider>);
}
test('<SuperBlock /> not expanded snapshot', () => {
const toggleSpy = sinon.spy();
const props = {
introNodes: mockIntroNodes,
isExpanded: false,
nodes: mockChallengeNodes,
superBlock: 'Super Block One',
toggleSuperBlock: toggleSpy
toggleSuperBlock: () => {}
};
const componentToRender = <SuperBlock {...props} />;
const component = renderer.render(componentToRender);
expect(component).toMatchSnapshot('superBlock-not-expanded');
const { container } = render(<SuperBlock {...props} />);
expect(container).toMatchSnapshot('superBlock-not-expanded');
});
test('<SuperBlock /> expanded snapshot', () => {
const toggleSpy = sinon.spy();
const props = {
introNodes: mockIntroNodes,
isExpanded: true,
nodes: mockChallengeNodes,
superBlock: 'Super Block One',
toggleSuperBlock: toggleSpy
toggleSuperBlock: () => {}
};
const componentToRender = <SuperBlock {...props} />;
const component = renderer.render(componentToRender);
expect(component).toMatchSnapshot('superBlock-expanded');
const { container } = renderWithRedux(<SuperBlock {...props} />);
expect(container).toMatchSnapshot('superBlock-expanded');
});
test('<SuperBlock should handle toggle clicks correctly', () => {
const toggleSpy = sinon.spy();
const toggleSpy = jest.fn();
const props = {
introNodes: mockIntroNodes,
isExpanded: false,
@ -52,30 +51,25 @@ test('<SuperBlock should handle toggle clicks correctly', () => {
superBlock: 'Super Block One',
toggleSuperBlock: toggleSpy
};
const componentToRender = <SuperBlock {...props} />;
const enzymeWrapper = Enzyme.shallow(componentToRender);
expect(toggleSpy.called).toBe(false);
expect(
enzymeWrapper
.find('.map-title')
.find('h4')
.text()
).toBe('Super Block One Certification (300\xa0hours)');
expect(enzymeWrapper.find('ul').length).toBe(0);
const { container, rerender } = renderWithRedux(<SuperBlock {...props} />);
enzymeWrapper.find('.map-title').simulate('click');
expect(toggleSpy).not.toHaveBeenCalled();
expect(container.querySelector('.map-title h4')).toHaveTextContent(
'Super Block One Certification (300 hours)'
);
expect(container.querySelector('ul')).not.toBeInTheDocument();
expect(toggleSpy.called).toBe(true);
expect(toggleSpy.calledWithExactly('Super Block One')).toBe(true);
fireEvent.click(container.querySelector('.map-title'));
enzymeWrapper.setProps({ ...props, isExpanded: true });
expect(toggleSpy).toHaveBeenCalledTimes(1);
expect(toggleSpy).toHaveBeenCalledWith('Super Block One');
expect(
enzymeWrapper
.find('.map-title')
.find('h4')
.text()
).toBe('Super Block One Certification (300\xa0hours)');
expect(enzymeWrapper.find('ul').length).toBe(1);
rerender(
<Provider store={createStore()}>
<SuperBlock {...props} isExpanded={true} />
</Provider>
);
expect(container.querySelector('ul')).toBeInTheDocument();
});

View File

@ -1,218 +1,449 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Block /> not expanded snapshot: block-not-expanded 1`] = `
<li
className="block "
>
<button
aria-expanded={false}
className="map-title"
onClick={[Function]}
<div>
<li
class="block "
>
<Caret />
<h4>
Block A
</h4>
<div
className="map-title-completed"
<button
aria-expanded="false"
class="map-title"
>
<span>
<GreenNotCompleted
style={
Object {
"height": "15px",
"marginRight": "10px",
"width": "15px",
}
}
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</span>
<span>
2/5
</span>
</div>
</button>
<ul />
</li>
</svg>
<h4>
Block A
</h4>
<div
class="map-title-completed"
>
<span>
<span
class="sr-only"
>
Not Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Not Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<span>
2/5
</span>
</div>
</button>
<ul />
</li>
</div>
`;
exports[`<Block expanded snapshot: block-expanded 1`] = `
<li
className="block open"
>
<button
aria-expanded={true}
className="map-title"
onClick={[Function]}
<div>
<li
class="block open"
>
<Caret />
<h4>
Block A
</h4>
<div
className="map-title-completed"
<button
aria-expanded="true"
class="map-title"
>
<span>
<GreenNotCompleted
style={
Object {
"height": "15px",
"marginRight": "10px",
"width": "15px",
}
}
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</span>
<span>
2/5
</span>
</div>
</button>
<ul>
<li
className="map-challenge-title"
id="introduction-to-block-a"
>
<span
className="badge map-badge"
</svg>
<h4>
Block A
</h4>
<div
class="map-title-completed"
>
<IntroInformation
style={
Object {
"height": "15px",
"marginRight": "10px",
"width": "15px",
}
}
/>
</span>
<mockConstructor
onClick={[Function]}
to="/super-block-one/block-a"
<span>
<span
class="sr-only"
>
Not Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Not Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<span>
2/5
</span>
</div>
</button>
<ul>
<li
class="map-challenge-title"
id="introduction-to-block-a"
>
Introduction to Block A
</mockConstructor>
</li>
<li
className="map-challenge-title map-challenge-title-completed"
id="challenge-one"
>
<span
className="badge map-badge"
<span
class="badge map-badge"
>
<span
class="sr-only"
>
IntroInformation
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
IntroInformation
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
<circle
cx="100"
cy="99"
fill="var(--primary-color)"
r="45"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<a
href="/super-block-one/block-a"
>
Introduction to Block A
</a>
</li>
<li
class="map-challenge-title map-challenge-title-completed"
id="challenge-one"
>
<GreenPass
style={
Object {
"height": "15px",
"marginRight": "10px",
"width": "15px",
}
}
/>
</span>
<mockConstructor
onClick={[Function]}
to="/super-block-one/block-a/challenge-one"
<span
class="badge map-badge"
>
<span
class="sr-only"
>
Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-color)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
/>
<rect
fill="var(--primary-background)"
height="30"
stroke="var(--primary-background)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
transform="rotate(-45, 120, 106.321)"
width="128.85878"
x="55.57059"
y="91.32089"
/>
<rect
fill="var(--primary-background)"
height="30"
stroke="var(--primary-background)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
transform="rotate(45, 66.75, 123.75)"
width="80.66548"
x="26.41726"
y="108.75"
/>
</g>
</svg>
</span>
<a
href="/super-block-one/block-a/challenge-one"
>
Challenge One
</a>
</li>
<li
class="map-challenge-title"
id="challenge-two"
>
Challenge One
</mockConstructor>
</li>
<li
className="map-challenge-title"
id="challenge-two"
>
<span
className="badge map-badge"
<span
class="badge map-badge"
>
<span
class="sr-only"
>
Not Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Not Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<a
href="/super-block-one/block-a/challenge-two"
>
Challenge Two
</a>
</li>
<li
class="map-challenge-title"
id="challenge-one"
>
<GreenNotCompleted
style={
Object {
"height": "15px",
"marginRight": "10px",
"width": "15px",
}
}
/>
</span>
<mockConstructor
onClick={[Function]}
to="/super-block-one/block-a/challenge-two"
<span
class="badge map-badge"
>
<span
class="sr-only"
>
Not Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Not Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<a
href="/super-block-two/block-a/challenge-one"
>
Challenge One
</a>
</li>
<li
class="map-challenge-title map-challenge-title-completed"
id="challenge-two"
>
Challenge Two
</mockConstructor>
</li>
<li
className="map-challenge-title"
id="challenge-one"
>
<span
className="badge map-badge"
<span
class="badge map-badge"
>
<span
class="sr-only"
>
Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-color)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
/>
<rect
fill="var(--primary-background)"
height="30"
stroke="var(--primary-background)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
transform="rotate(-45, 120, 106.321)"
width="128.85878"
x="55.57059"
y="91.32089"
/>
<rect
fill="var(--primary-background)"
height="30"
stroke="var(--primary-background)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
transform="rotate(45, 66.75, 123.75)"
width="80.66548"
x="26.41726"
y="108.75"
/>
</g>
</svg>
</span>
<a
href="/super-block-two/block-a/challenge-two"
>
Challenge Two
</a>
</li>
<li
class="map-challenge-title"
id="challenge-one"
>
<GreenNotCompleted
style={
Object {
"height": "15px",
"marginRight": "10px",
"width": "15px",
}
}
/>
</span>
<mockConstructor
onClick={[Function]}
to="/super-block-two/block-a/challenge-one"
>
Challenge One
</mockConstructor>
</li>
<li
className="map-challenge-title map-challenge-title-completed"
id="challenge-two"
>
<span
className="badge map-badge"
>
<GreenPass
style={
Object {
"height": "15px",
"marginRight": "10px",
"width": "15px",
}
}
/>
</span>
<mockConstructor
onClick={[Function]}
to="/super-block-two/block-a/challenge-two"
>
Challenge Two
</mockConstructor>
</li>
<li
className="map-challenge-title"
id="challenge-one"
>
<span
className="badge map-badge"
>
<GreenNotCompleted
style={
Object {
"height": "15px",
"marginRight": "10px",
"width": "15px",
}
}
/>
</span>
<mockConstructor
onClick={[Function]}
to="/super-block-three/block-a/challenge-one"
>
Challenge One
</mockConstructor>
</li>
</ul>
</li>
<span
class="badge map-badge"
>
<span
class="sr-only"
>
Not Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Not Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<a
href="/super-block-three/block-a/challenge-one"
>
Challenge One
</a>
</li>
</ul>
</li>
</div>
`;

View File

@ -1,158 +1,242 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<SuperBlock /> expanded snapshot: superBlock-expanded 1`] = `
<li
className="superblock open"
id="super-block-one"
>
<button
aria-expanded={true}
className="map-title"
onClick={[Function]}
<div>
<li
class="superblock open"
id="super-block-one"
>
<Caret />
<h4>
Super Block One Certification (300 hours)
</h4>
</button>
<ul>
<Connect(Block)
blockDashedName="block-a"
challenges={
Array [
Object {
"block": "block-a",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-one/block-a/challenge-one",
},
"id": "a",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-a",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block A",
"slug": "/super-block-one/block-a/challenge-two",
},
"id": "b",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge Two",
},
]
}
intro={
Object {
"fields": Object {
"slug": "/super-block-one/block-a",
},
"frontmatter": Object {
"block": "Block A",
"title": "Introduction to Block A",
},
}
}
/>
<Connect(Block)
blockDashedName="block-b"
challenges={
Array [
Object {
"block": "block-b",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-one/block-b/challenge-one",
},
"id": "c",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
Object {
"block": "block-b",
"dashedName": "challenge-two",
"fields": Object {
"blockName": "Block B",
"slug": "/super-block-one/block-b/challenge-two",
},
"id": "d",
"isPrivate": false,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge Two",
},
]
}
intro={
Object {
"fields": Object {
"slug": "/super-block-one/block-b",
},
"frontmatter": Object {
"block": "Block B",
"title": "Introduction to Block B",
},
}
}
/>
<Connect(Block)
blockDashedName="block-c"
challenges={
Array [
Object {
"block": "block-c",
"dashedName": "challenge-one",
"fields": Object {
"blockName": "Block C",
"slug": "/super-block-one/block-c/challenge-one",
},
"id": "e",
"isPrivate": true,
"isRequired": false,
"superBlock": "Super Block One",
"title": "Challenge One",
},
]
}
intro={
Object {
"fields": Object {
"slug": "/super-block-one/block-c",
},
"frontmatter": Object {
"block": "Block C",
"title": "Introduction to Block C",
},
}
}
/>
</ul>
</li>
<button
aria-expanded="true"
class="map-title"
>
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</svg>
<h4>
Super Block One Certification (300 hours)
</h4>
</button>
<ul>
<li
class="block "
>
<button
aria-expanded="false"
class="map-title"
>
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</svg>
<h4>
Block A
</h4>
<div
class="map-title-completed"
>
<span>
<span
class="sr-only"
>
Not Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Not Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<span>
0/2
</span>
</div>
</button>
<ul />
</li>
<li
class="block "
>
<button
aria-expanded="false"
class="map-title"
>
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</svg>
<h4>
Block B
</h4>
<div
class="map-title-completed"
>
<span>
<span
class="sr-only"
>
Not Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Not Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<span>
0/2
</span>
</div>
</button>
<ul />
</li>
<li
class="block "
>
<button
aria-expanded="false"
class="map-title"
>
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</svg>
<h4>
Block C
</h4>
<div
class="map-title-completed"
>
<span>
<span
class="sr-only"
>
Not Passed
</span>
<svg
height="50"
style="height: 15px; margin-right: 10px; width: 15px;"
viewBox="0 0 200 200"
width="50"
xmlns="http://www.w3.org/2000/svg"
>
<g>
<title>
Not Passed
</title>
<circle
cx="100"
cy="99"
fill="var(--primary-background)"
r="95"
stroke="var(--primary-color)"
stroke-dasharray="null"
stroke-linecap="null"
stroke-linejoin="null"
stroke-width="10"
/>
</g>
</svg>
</span>
<span>
0/1
</span>
</div>
</button>
<ul />
</li>
</ul>
</li>
</div>
`;
exports[`<SuperBlock /> not expanded snapshot: superBlock-not-expanded 1`] = `
<li
className="superblock "
id="super-block-one"
>
<button
aria-expanded={false}
className="map-title"
onClick={[Function]}
<div>
<li
class="superblock "
id="super-block-one"
>
<Caret />
<h4>
Super Block One Certification (300 hours)
</h4>
</button>
</li>
<button
aria-expanded="false"
class="map-title"
>
<svg
viewBox="0 0 100 100"
width="25px"
>
<polygon
points="-6.04047,17.1511 81.8903,58.1985 -3.90024,104.196"
style="stroke: var(--primary-color); fill: var(--primary-color); stroke-width: 1px;"
transform="matrix(0.999729, 0.023281, -0.023281, 0.999729, 7.39321, -10.0425)"
/>
</svg>
<h4>
Super Block One Certification (300 hours)
</h4>
</button>
</li>
</div>
`;

View File

@ -1,30 +1,26 @@
/* global expect */
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import renderer from 'react-test-renderer';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { render } from '@testing-library/react';
import BlockSaveButton from './BlockSaveButton';
Enzyme.configure({ adapter: new Adapter() });
test('<BlockSaveButton /> snapshot', () => {
const component = renderer.create(<BlockSaveButton />);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
const { container } = render(<BlockSaveButton />);
expect(container).toMatchSnapshot();
});
test('Button text should default to "Save"', () => {
const enzymeWrapper = Enzyme.render(<BlockSaveButton />);
const { getByRole } = render(<BlockSaveButton />);
expect(enzymeWrapper.text()).toBe('Save');
expect(getByRole('button')).toHaveTextContent('Save');
});
test('Button text should match "children"', () => {
const enzymeWrapper = Enzyme.render(
<BlockSaveButton>My Text Here</BlockSaveButton>
);
const testText = 'My Text Here';
const { getByRole } = render(<BlockSaveButton>{testText}</BlockSaveButton>);
expect(enzymeWrapper.text()).toBe('My Text Here');
expect(getByRole('button')).toHaveTextContent(testText);
});

View File

@ -1,16 +1,12 @@
/* global expect */
import React from 'react';
import renderer from 'react-test-renderer';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { render } from '@testing-library/react';
import BlockSaveWrapper from './BlockSaveWrapper';
Enzyme.configure({ adapter: new Adapter() });
test('<BlockSaveWrapper /> snapshot', () => {
const component = renderer.create(<BlockSaveWrapper />);
let tree = component.toJSON();
expect(tree).toMatchSnapshot();
const { container } = render(<BlockSaveWrapper />);
expect(container).toMatchSnapshot();
});

View File

@ -1,11 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<BlockSaveButton /> snapshot 1`] = `
<button
className="btn btn-primary btn-block"
disabled={false}
type="submit"
>
Save
</button>
<div>
<button
class="btn btn-primary btn-block"
type="submit"
>
Save
</button>
</div>
`;

View File

@ -1,11 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<BlockSaveWrapper /> snapshot 1`] = `
<div
style={
Object {
"padding": "0 15px",
}
}
/>
<div>
<div
style="padding: 0px 15px;"
/>
</div>
`;

View File

@ -1,15 +1,11 @@
/* global expect */
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import Enzyme, { shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Link from '../helpers/Link';
import renderer from 'react-test-renderer';
import { render } from '@testing-library/react';
import Profile from './Profile';
Enzyme.configure({ adapter: new Adapter() });
const userProps = {
user: {
profileUI: {
@ -45,7 +41,8 @@ const userProps = {
username: 'string',
website: 'string',
yearsTopContributor: []
}
},
navigate: () => {}
};
const myProfileProps = {
@ -60,29 +57,26 @@ const notMyProfileProps = {
describe('<Profile/>', () => {
it('renders the settings button on your own profile', () => {
const profileToRender = <Profile {...myProfileProps} />;
const profile = shallow(profileToRender);
expect(
profile
.find(Link)
.first()
.prop('to')
).toBe('/settings');
const { getByText } = render(<Profile {...myProfileProps} />);
expect(getByText('Update my settings')).toHaveAttribute(
'href',
'/settings'
);
});
it('renders the report button on another persons profile', () => {
const profileToRender = <Profile {...notMyProfileProps} />;
const profile = shallow(profileToRender);
expect(
profile
.find(Link)
.first()
.prop('to')
).toBe('/user/string/report-user');
const { getByText } = render(<Profile {...notMyProfileProps} />);
expect(getByText('Report This User')).toHaveAttribute(
'href',
'/user/string/report-user'
);
});
it('renders correctly', () => {
const tree = renderer.create(<Profile {...notMyProfileProps} />).toJSON();
expect(tree).toMatchSnapshot();
const { container } = render(<Profile {...notMyProfileProps} />);
expect(container).toMatchSnapshot();
});
});

View File

@ -1,47 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<Profile/> renders correctly 1`] = `
Array [
<div>
<div
className="spacer"
style={
Object {
"height": "1px",
"padding": "15px 0",
}
}
/>,
class="spacer"
style="padding: 15px 0px; height: 1px;"
/>
<div
className="container"
class="container"
>
<div
className="spacer"
style={
Object {
"height": "1px",
"padding": "15px 0",
}
}
class="spacer"
style="padding: 15px 0px; height: 1px;"
/>
<div>
<div
className="row"
class="row"
>
<div
className="avatar-container col-xs-12"
class="avatar-container col-xs-12"
>
<img
alt="string's avatar"
className="avatar img-responsive"
class="avatar img-responsive"
src="string"
/>
</div>
</div>
<div
className="row"
class="row"
>
<div
className="text-center social-media-icons col-sm-6 col-sm-offset-3"
class="text-center social-media-icons col-sm-6 col-sm-offset-3"
>
<a
aria-label="Link to string's LinkedIn"
@ -51,19 +41,17 @@ Array [
>
<svg
aria-hidden="true"
className="svg-inline--fa fa-linkedin fa-w-14 fa-2x "
class="svg-inline--fa fa-linkedin fa-w-14 fa-2x "
data-icon="linkedin"
data-prefix="fab"
focusable="false"
role="img"
style={Object {}}
viewBox="0 0 448 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M416 32H31.9C14.3 32 0 46.5 0 64.3v383.4C0 465.5 14.3 480 31.9 480H416c17.6 0 32-14.5 32-32.3V64.3c0-17.8-14.4-32.3-32-32.3zM135.4 416H69V202.2h66.5V416zm-33.2-243c-21.3 0-38.5-17.3-38.5-38.5S80.9 96 102.2 96c21.2 0 38.5 17.3 38.5 38.5 0 21.3-17.2 38.5-38.5 38.5zm282.1 243h-66.4V312c0-24.8-.5-56.7-34.5-56.7-34.6 0-39.9 27-39.9 54.9V416h-66.4V202.2h63.7v29.2h.9c8.9-16.8 30.6-34.5 62.9-34.5 67.2 0 79.7 44.3 79.7 101.9V416z"
fill="currentColor"
style={Object {}}
/>
</svg>
</a>
@ -75,19 +63,17 @@ Array [
>
<svg
aria-hidden="true"
className="svg-inline--fa fa-github fa-w-16 fa-2x "
class="svg-inline--fa fa-github fa-w-16 fa-2x "
data-icon="github"
data-prefix="fab"
focusable="false"
role="img"
style={Object {}}
viewBox="0 0 496 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"
fill="currentColor"
style={Object {}}
/>
</svg>
</a>
@ -99,19 +85,17 @@ Array [
>
<svg
aria-hidden="true"
className="svg-inline--fa fa-link fa-w-16 fa-2x "
class="svg-inline--fa fa-link fa-w-16 fa-2x "
data-icon="link"
data-prefix="fas"
focusable="false"
role="img"
style={Object {}}
viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M326.612 185.391c59.747 59.809 58.927 155.698.36 214.59-.11.12-.24.25-.36.37l-67.2 67.2c-59.27 59.27-155.699 59.262-214.96 0-59.27-59.26-59.27-155.7 0-214.96l37.106-37.106c9.84-9.84 26.786-3.3 27.294 10.606.648 17.722 3.826 35.527 9.69 52.721 1.986 5.822.567 12.262-3.783 16.612l-13.087 13.087c-28.026 28.026-28.905 73.66-1.155 101.96 28.024 28.579 74.086 28.749 102.325.51l67.2-67.19c28.191-28.191 28.073-73.757 0-101.83-3.701-3.694-7.429-6.564-10.341-8.569a16.037 16.037 0 0 1-6.947-12.606c-.396-10.567 3.348-21.456 11.698-29.806l21.054-21.055c5.521-5.521 14.182-6.199 20.584-1.731a152.482 152.482 0 0 1 20.522 17.197zM467.547 44.449c-59.261-59.262-155.69-59.27-214.96 0l-67.2 67.2c-.12.12-.25.25-.36.37-58.566 58.892-59.387 154.781.36 214.59a152.454 152.454 0 0 0 20.521 17.196c6.402 4.468 15.064 3.789 20.584-1.731l21.054-21.055c8.35-8.35 12.094-19.239 11.698-29.806a16.037 16.037 0 0 0-6.947-12.606c-2.912-2.005-6.64-4.875-10.341-8.569-28.073-28.073-28.191-73.639 0-101.83l67.2-67.19c28.239-28.239 74.3-28.069 102.325.51 27.75 28.3 26.872 73.934-1.155 101.96l-13.087 13.087c-4.35 4.35-5.769 10.79-3.783 16.612 5.864 17.194 9.042 34.999 9.69 52.721.509 13.906 17.454 20.446 27.294 10.606l37.106-37.106c59.271-59.259 59.271-155.699.001-214.959z"
fill="currentColor"
style={Object {}}
/>
</svg>
</a>
@ -123,19 +107,17 @@ Array [
>
<svg
aria-hidden="true"
className="svg-inline--fa fa-twitter fa-w-16 fa-2x "
class="svg-inline--fa fa-twitter fa-w-16 fa-2x "
data-icon="twitter"
data-prefix="fab"
focusable="false"
role="img"
style={Object {}}
viewBox="0 0 512 512"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"
fill="currentColor"
style={Object {}}
/>
</svg>
</a>
@ -143,7 +125,7 @@ Array [
</div>
<br />
<h2
className="text-center username"
class="text-center username"
>
@
string
@ -151,16 +133,11 @@ Array [
<br />
</div>
<div
className="spacer"
style={
Object {
"height": "1px",
"padding": "15px 0",
}
}
class="spacer"
style="padding: 15px 0px; height: 1px;"
/>
<div
className="text-center row"
class="text-center row"
>
<a
href="/user/string/report-user"
@ -169,14 +146,9 @@ Array [
</a>
</div>
<div
className="spacer"
style={
Object {
"height": "1px",
"padding": "15px 0",
}
}
class="spacer"
style="padding: 15px 0px; height: 1px;"
/>
</div>,
]
</div>
</div>
`;

View File

@ -1,49 +1,57 @@
/* global expect */
import '@testing-library/jest-dom/extend-expect';
import React from 'react';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { render } from '@testing-library/react';
import { CertificationSettings } from './Certification';
Enzyme.configure({ adapter: new Adapter() });
describe('<certification />', () => {
// shallow rendering does not render children component
// form buttons are not included in shallow render
it('Should render show cert button for calimed legacy cert', () => {
const wrapper = Enzyme.shallow(
const { container } = render(
<CertificationSettings {...defaultTestProps} />
);
expect(
wrapper.find('#button-legacy-data-visualization').props().children
).toEqual('Show Certification');
container.querySelector('#button-legacy-data-visualization')
).toHaveTextContent('Show Certification');
});
it('Should link show cert button to the calimed legacy cert', () => {
const wrapper = Enzyme.shallow(
const { container } = render(
<CertificationSettings {...defaultTestProps} />
);
expect(
wrapper.find('#button-legacy-data-visualization').props().href
).toEqual('/certification/developementuser/legacy-data-visualization');
container.querySelector('#button-legacy-data-visualization')
).toHaveAttribute(
'href',
'/certification/developementuser/legacy-data-visualization'
);
});
// full forms with unclaimed certs should should not shallow render button
it('Should not render show cert button for unclaimed full form', () => {
const wrapper = Enzyme.shallow(
const { container } = render(
<CertificationSettings {...defaultTestProps} />
);
expect(wrapper.exists('#button-legacy-back-end')).toEqual(false);
expect(
container.querySelector('#button-legacy-back-end')
).not.toBeInTheDocument();
});
// empty forms with unclaimed certs should should not shallow render button
it('Should not render show cert button for empty form', () => {
const wrapper = Enzyme.shallow(
const { container } = render(
<CertificationSettings {...defaultTestProps} />
);
expect(wrapper.exists('#button-legacy-front-end')).toEqual(false);
expect(
container.querySelector('#button-legacy-front-end')
).not.toBeInTheDocument();
});
});

41
package-lock.json generated
View File

@ -5313,7 +5313,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -5334,12 +5335,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -5354,17 +5357,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -5481,7 +5487,8 @@
"inherits": {
"version": "2.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -5493,6 +5500,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -5507,6 +5515,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -5514,12 +5523,14 @@
"minimist": {
"version": "0.0.8",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.3.5",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -5538,6 +5549,7 @@
"version": "0.5.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "0.0.8"
}
@ -5618,7 +5630,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -5630,6 +5643,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -5715,7 +5729,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -5751,6 +5766,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -5770,6 +5786,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -5813,12 +5830,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},