mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Node: Add tests for "timers" module (#11080)
This commit is contained in:
@@ -21,6 +21,7 @@ import * as os from "os";
|
||||
import * as vm from "vm";
|
||||
import * as string_decoder from "string_decoder";
|
||||
import * as stream from "stream";
|
||||
import * as timers from "timers";
|
||||
|
||||
// Specifically test buffer module regression.
|
||||
import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer";
|
||||
@@ -988,6 +989,31 @@ namespace vm_tests {
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/// Timers tests : https://nodejs.org/api/timers.html
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
namespace timers_tests {
|
||||
{
|
||||
let immediateId = timers.setImmediate(function(){ console.log("immediate"); });
|
||||
timers.clearImmediate(immediateId);
|
||||
}
|
||||
{
|
||||
let counter = 0;
|
||||
let timeout = timers.setInterval(function(){ console.log("interval"); }, 20);
|
||||
timeout.unref();
|
||||
timeout.ref();
|
||||
timers.clearInterval(timeout);
|
||||
}
|
||||
{
|
||||
let counter = 0;
|
||||
let timeout = timers.setTimeout(function(){ console.log("timeout"); }, 20);
|
||||
timeout.unref();
|
||||
timeout.ref();
|
||||
timers.clearTimeout(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////
|
||||
/// Errors Tests : https://nodejs.org/api/errors.html ///
|
||||
/////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user