Skip to content

Commit

Permalink
Optimize test
Browse files Browse the repository at this point in the history
  • Loading branch information
theogravity committed Jul 14, 2024
1 parent 5efccf3 commit 45bdbf9
Showing 1 changed file with 4 additions and 18 deletions.
22 changes: 4 additions & 18 deletions test/DownloadInitiator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,23 +290,6 @@ describe("DownloadInitiator", () => {
expect(downloadInitiator.callbackDispatcher.onDownloadInterrupted).toHaveBeenCalledWith(mockDownloadData);
});

it("should not call the item updated event if the download was paused", async () => {
const downloadInitiator = new DownloadInitiator({});
downloadInitiator.downloadData = mockDownloadData;

determineFilePath.mockReturnValueOnce("/some/path/test.txt");

await downloadInitiator.generateOnWillDownload({
callbacks,
})(mockEvent, mockItem, mockWebContents);

await jest.runAllTimersAsync();
mockItem.pause();
mockEmitter.emit("updated", "");

expect(downloadInitiator.callbackDispatcher.onDownloadProgress).not.toHaveBeenCalled();
});

it("should call the item updated event if the download was paused and resumed", async () => {
const downloadInitiator = new DownloadInitiator({});
downloadInitiator.downloadData = mockDownloadData;
Expand All @@ -319,10 +302,13 @@ describe("DownloadInitiator", () => {
})(mockEvent, mockItem, mockWebContents);

await jest.runAllTimersAsync();

mockItem.pause();
mockItem.resume();
mockEmitter.emit("updated", "", "progressing");
expect(downloadInitiator.callbackDispatcher.onDownloadProgress).not.toHaveBeenCalled();

mockItem.resume();
mockEmitter.emit("updated", "", "progressing");
expect(downloadInitiator.callbackDispatcher.onDownloadProgress).toHaveBeenCalled();
})
});
Expand Down

0 comments on commit 45bdbf9

Please sign in to comment.