• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('./common');
3const assert = require('assert');
4const timers = require('timers');
5const promisify = require('..');
6
7common.crashOnUnhandledRejection();
8
9const setTimeout = promisify(timers.setTimeout);
10const setImmediate = promisify(timers.setImmediate);
11
12{
13  const promise = setTimeout(1);
14  promise.then(common.mustCall((value) => {
15    assert.strictEqual(value, undefined);
16  }));
17}
18
19{
20  const promise = setTimeout(1, 'foobar');
21  promise.then(common.mustCall((value) => {
22    assert.strictEqual(value, 'foobar');
23  }));
24}
25
26{
27  const promise = setImmediate();
28  promise.then(common.mustCall((value) => {
29    assert.strictEqual(value, undefined);
30  }));
31}
32
33{
34  const promise = setImmediate('foobar');
35  promise.then(common.mustCall((value) => {
36    assert.strictEqual(value, 'foobar');
37  }));
38}
39