feat: show progress while updating/installing dependencies

This commit is contained in:
Jelle Glebbeek
2021-10-27 02:18:16 +02:00
parent bc8b23e845
commit d4b62e9a9f
4 changed files with 65 additions and 40 deletions

View File

@@ -136,7 +136,7 @@ describe("downloadUpdate", () => {
const mockReadable = new PassThrough();
const mockWriteable = new PassThrough();
jest.spyOn(fs, 'createWriteStream').mockReturnValueOnce(mockWriteable);
jest.spyOn(axios, 'get').mockResolvedValue({ data: mockReadable });
jest.spyOn(axios, 'get').mockResolvedValue({ data: mockReadable, headers: { "content-length": 1200 } });
setTimeout(() => {
mockWriteable.emit('error', "Test error");
}, 100);
@@ -150,7 +150,7 @@ describe("downloadUpdate", () => {
const mockReadable = new PassThrough();
const mockWriteable = new PassThrough();
jest.spyOn(fs, 'createWriteStream').mockReturnValueOnce(mockWriteable);
jest.spyOn(axios, 'get').mockResolvedValue({ data: mockReadable });
jest.spyOn(axios, 'get').mockResolvedValue({ data: mockReadable, headers: { "content-length": 1200 } });
setTimeout(() => {
mockWriteable.emit('close');
}, 100);

View File

@@ -106,7 +106,7 @@ describe('checkUpdate', () => {
jest.spyOn(instance, 'getRemoteVersion').mockResolvedValue(["link", "v2.0.0"]);
return instance.checkUpdate().then(() => {
expect(downloadUpdateSpy).toBeCalledTimes(2);
expect(instance.win.webContents.send).toBeCalledTimes(1);
expect(instance.win.webContents.send).toBeCalledTimes(2);
});
});
it('downloads the latest remote version when local version is different', () => {
@@ -117,7 +117,7 @@ describe('checkUpdate', () => {
jest.spyOn(instance, 'getRemoteVersion').mockResolvedValue({ remoteUrl: "link", remoteVersion: "2021.10.10" });
return instance.checkUpdate().then(() => {
expect(downloadUpdateSpy).toBeCalledTimes(2);
expect(instance.win.webContents.send).toBeCalledTimes(1);
expect(instance.win.webContents.send).toBeCalledTimes(2);
});
});
});