2019-05-31 11:56:07 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
import {promisify} from 'util';
|
|
|
|
|
|
|
|
describe('node timer', () => {
|
|
|
|
it('util.promisify should work with setTimeout', (done: DoneFn) => {
|
|
|
|
const setTimeoutPromise = promisify(setTimeout);
|
|
|
|
setTimeoutPromise(50, 'value')
|
|
|
|
.then(
|
|
|
|
value => {
|
|
|
|
expect(value).toEqual('value');
|
|
|
|
done();
|
|
|
|
},
|
2020-04-13 19:40:21 -04:00
|
|
|
error => {
|
|
|
|
fail(`should not be here with error: ${error}.`);
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
it('util.promisify should work with setImmediate', (done: DoneFn) => {
|
|
|
|
const setImmediatePromise = promisify(setImmediate);
|
|
|
|
setImmediatePromise('value').then(
|
|
|
|
value => {
|
|
|
|
expect(value).toEqual('value');
|
|
|
|
done();
|
|
|
|
},
|
2020-04-13 19:40:21 -04:00
|
|
|
error => {
|
|
|
|
fail(`should not be here with error: ${error}.`);
|
|
|
|
});
|
2019-05-31 11:56:07 -04:00
|
|
|
});
|
|
|
|
});
|