Skip to content

Commit

Permalink
test(multi file upload): Multi file upload tests (#1091)
Browse files Browse the repository at this point in the history
* test(file upload): wip - tests

* test(multifile upload): add tests for multi file upload component

* test(multi file upload): complete tests for multiple files and accessibility
  • Loading branch information
chrispymm authored Jan 17, 2025
1 parent 32e6b58 commit bc74252
Show file tree
Hide file tree
Showing 5 changed files with 676 additions and 5 deletions.
7 changes: 5 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const config = {
testEnvironment: "jsdom",
testEnvironmentOptions: {
url: "https://design-patterns.service.juice.gov.uk/",
},
setupFilesAfterEnv: ["./jest.setup.js"],
setupFilesAfterEnv: ["./jest.setup.js", "jest-sinon"],
// See: https://github.com/sinonjs/sinon/issues/2522#issuecomment-1612555284
moduleNameMapper: {
sinon: "<rootDir>/node_modules/sinon/pkg/sinon.js",
},
};
module.exports = config;
143 changes: 142 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"jest": "^29.2.2",
"jest-axe": "^9.0.0",
"jest-environment-jsdom": "^29.7.0",
"jest-sinon": "^1.1.0",
"jquery": "^3.7.1",
"js-beautify": "^1.13.13",
"lodash": "^4.17.21",
Expand All @@ -98,7 +99,8 @@
"mock-match-media": "^0.4.3",
"npm-run-all2": "^6.0.0",
"postcss": "^8.4.31",
"semantic-release": "^23.0.0"
"semantic-release": "^23.0.0",
"sinon": "^19.0.2"
},
"config": {
"commitizen": {
Expand Down
2 changes: 1 addition & 1 deletion src/moj/components/multi-file-upload/multi-file-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if(MOJFrontend.dragAndDropSupported() && MOJFrontend.formDataSupported() && MOJF
this.uploadFiles(e.currentTarget.files);
this.fileInput.replaceWith($(e.currentTarget).val('').clone(true));
this.setupFileInput();
this.fileInput.focus();
this.fileInput.get(0).focus();
};

MOJFrontend.MultiFileUpload.prototype.onFileFocus = function(e) {
Expand Down
Loading

0 comments on commit bc74252

Please sign in to comment.