|
|
@ -63,11 +63,20 @@ describe("MainActions", () => { |
|
|
|
it("should call uploadFile when a file is selected for upload", () => { |
|
|
|
it("should call uploadFile when a file is selected for upload", () => { |
|
|
|
const uploadFile = jest.fn() |
|
|
|
const uploadFile = jest.fn() |
|
|
|
const wrapper = shallow(<MainActions uploadFile={uploadFile} />) |
|
|
|
const wrapper = shallow(<MainActions uploadFile={uploadFile} />) |
|
|
|
const file = new Blob(["file content"], { type: "text/plain" }) |
|
|
|
const files = [new Blob(["file content"], { type: "text/plain" })] |
|
|
|
wrapper.find("#file-input").simulate("change", { |
|
|
|
const input = wrapper.find("#file-input") |
|
|
|
|
|
|
|
const event = { |
|
|
|
preventDefault: jest.fn(), |
|
|
|
preventDefault: jest.fn(), |
|
|
|
target: { files: [file] } |
|
|
|
target: { |
|
|
|
}) |
|
|
|
files: { |
|
|
|
expect(uploadFile).toHaveBeenCalledWith(file) |
|
|
|
length: files.length, |
|
|
|
|
|
|
|
item: function(index) { |
|
|
|
|
|
|
|
return files[index] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
input.simulate("change", event) |
|
|
|
|
|
|
|
expect(uploadFile).toHaveBeenCalledWith(files[0]) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|