feat: add getPercentComplete / getCurrentBytesPerSecond / getEndTime to DownloadItem (#42805)

feat: getCurrentSpeed / getPercentComplete / getEndTime on DownloadItem
This commit is contained in:
Theo Gravity 2024-07-15 16:32:44 -07:00 committed by GitHub
parent 0fddfd1b28
commit bab3fcc9ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 1 deletions

View file

@ -889,13 +889,21 @@ describe('session module', () => {
}
});
const today = Math.floor(Date.now() / 1000);
const item = await downloadDone;
expect(item.getState()).to.equal('completed');
expect(item.getFilename()).to.equal('mock.pdf');
expect(item.getMimeType()).to.equal('application/pdf');
expect(item.getReceivedBytes()).to.equal(mockPDF.length);
expect(item.getTotalBytes()).to.equal(mockPDF.length);
expect(item.getPercentComplete()).to.equal(100);
expect(item.getCurrentBytesPerSecond()).to.equal(0);
expect(item.getContentDisposition()).to.equal(contentDisposition);
const start = item.getStartTime();
const end = item.getEndTime();
expect(start).to.be.greaterThan(today);
expect(end).to.be.greaterThan(start);
});
it('throws when called with invalid headers', () => {