feat(fs/abstract#rmdir): implement timeout

This commit is contained in:
Julien Fontanet 2018-12-05 15:32:13 +01:00
parent 3814a261d6
commit 48c3748c28
2 changed files with 13 additions and 1 deletions

View File

@ -274,7 +274,7 @@ export default class RemoteHandlerAbstract {
}
async rmdir(dir: string): Promise<void> {
await this._rmdir(this[kResolve](dir))
await timeout.call(this._rmdir(this[kResolve](dir)), this._timeout)
}
async rmtree(dir: string): Promise<void> {

View File

@ -100,6 +100,18 @@ describe('rename()', () => {
})
})
describe('rmdir()', () => {
it(`throws in case of timeout`, async () => {
const testHandler = new TestHandler({
rmdir: () => new Promise(() => {}),
})
const promise = testHandler.rmdir('dir')
jest.advanceTimersByTime(TIMEOUT)
await expect(promise).rejects.toThrowError(TimeoutError)
})
})
describe('unlink()', () => {
it(`throws in case of timeout`, async () => {
const testHandler = new TestHandler({