mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-03-10 13:08:21 +01:00
Fix Et2File tests broken by 6dae21b311
This commit is contained in:
parent
879ac933cc
commit
12849d4153
@ -176,6 +176,10 @@ export class Et2File extends Et2InputWidget(LitElement)
|
|||||||
disconnectedCallback()
|
disconnectedCallback()
|
||||||
{
|
{
|
||||||
super.disconnectedCallback();
|
super.disconnectedCallback();
|
||||||
|
if(this._uploadDelayTimeout)
|
||||||
|
{
|
||||||
|
window.clearTimeout(this._uploadDelayTimeout);
|
||||||
|
}
|
||||||
if(this.resumable)
|
if(this.resumable)
|
||||||
{
|
{
|
||||||
this.resumable.cancel();
|
this.resumable.cancel();
|
||||||
@ -345,7 +349,7 @@ export class Et2File extends Et2InputWidget(LitElement)
|
|||||||
{
|
{
|
||||||
this._uploadPending = {};
|
this._uploadPending = {};
|
||||||
this._uploadDelayTimeout = null;
|
this._uploadDelayTimeout = null;
|
||||||
setTimeout(this.resumable.upload);
|
window.setTimeout(this.resumable.upload);
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ describe('Et2File Component', async() =>
|
|||||||
assert.isTrue(clickSpy.calledOnce);
|
assert.isTrue(clickSpy.calledOnce);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should dispatch a change event when a file is added', async() =>
|
it('should dispatch a change event when a file is uploaded', async() =>
|
||||||
{
|
{
|
||||||
const file = new File(['content'], 'test.txt', {type: 'text/plain'});
|
const file = new File(['content'], 'test.txt', {type: 'text/plain'});
|
||||||
const fileList = {
|
const fileList = {
|
||||||
@ -165,16 +165,14 @@ describe('Et2File Component', async() =>
|
|||||||
const listener = oneEvent(element, 'et2-add');
|
const listener = oneEvent(element, 'et2-add');
|
||||||
const clock = sinon.useFakeTimers();
|
const clock = sinon.useFakeTimers();
|
||||||
element.addFile(file);
|
element.addFile(file);
|
||||||
await element.updateComplete;
|
|
||||||
const event = await listener;
|
const event = await listener;
|
||||||
|
// Wait for progress
|
||||||
|
clock.tick(101);
|
||||||
|
await Promise.allSettled(Object.values(element._uploadPending));
|
||||||
|
clock.tick(1);
|
||||||
|
|
||||||
const fileInfo = element.files[0];
|
const fileInfo = element.files[0];
|
||||||
|
|
||||||
const fileItem = <Et2FileItem>element.findFileItem(fileInfo.file);
|
const fileItem = <Et2FileItem>element.findFileItem(fileInfo.file);
|
||||||
|
|
||||||
// Et2File waits 100 ms before upload starts
|
|
||||||
clock.tick(101);
|
|
||||||
await fileItem.updateComplete;
|
await fileItem.updateComplete;
|
||||||
|
|
||||||
assert.strictEqual(fileItem.progress, 50, 'File progress should be updated');
|
assert.strictEqual(fileItem.progress, 50, 'File progress should be updated');
|
||||||
|
@ -79,6 +79,8 @@ class ResumableStub
|
|||||||
{
|
{
|
||||||
this.files = [];
|
this.files = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pause() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ResumableStub;
|
export default ResumableStub;
|
||||||
|
Loading…
Reference in New Issue
Block a user