1
0
Fork 0
js-utils/test/utils/TestSignal.ts

21 lines
580 B
TypeScript
Raw Normal View History

import { expect } from 'chai';
import { timeout } from '../../src/utils/Async';
import { signal, SIGNAL_RESET } from '../../src/utils/Signal';
import { describeLeaks, itLeaks } from '../helpers/async';
const MAX_SIGNAL_TIME = 500;
describeLeaks('signal utils', async () => {
itLeaks('should wait for a signal', async () => {
const signalPromise = signal(SIGNAL_RESET);
process.kill(process.pid, SIGNAL_RESET);
await timeout(MAX_SIGNAL_TIME, signalPromise);
const signalValue = await signalPromise;
expect(signalValue).to.equal(SIGNAL_RESET);
});
});