2020-03-31 02:31:51 +00:00
|
|
|
import { expect } from 'chai';
|
|
|
|
|
2022-10-08 19:10:17 +00:00
|
|
|
import { timeout } from '../../src/Async.js';
|
|
|
|
import { signal, SIGNAL_RESET } from '../../src/Signal.js';
|
2020-03-31 02:31:51 +00:00
|
|
|
|
|
|
|
const MAX_SIGNAL_TIME = 500;
|
|
|
|
|
2020-06-30 13:14:30 +00:00
|
|
|
describe('signal utils', async () => {
|
|
|
|
it('should wait for a signal', async () => {
|
2020-03-31 02:31:51 +00:00
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|