mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
22 lines
681 B
Text
22 lines
681 B
Text
|
import Interruptible from '../../src/shared/interruptible'
|
||
|
|
||
|
describe("Interruptible", () => {
|
||
|
describe("when interrupted with forceReject", () => {
|
||
|
it("the run method rejects immediately", async () => {
|
||
|
function* neverResolves() {
|
||
|
yield new Promise(() => {})
|
||
|
}
|
||
|
const interruptible = new Interruptible()
|
||
|
const promise = interruptible.run(neverResolves)
|
||
|
interruptible.interrupt({forceReject: true})
|
||
|
try {
|
||
|
await promise;
|
||
|
} catch (err) {
|
||
|
expect(/interrupted/i.test(err.toString())).toEqual(true)
|
||
|
}
|
||
|
// The promse never resolves, so if it doesn't reject,
|
||
|
// this test will timeout.
|
||
|
})
|
||
|
})
|
||
|
})
|