This repository has been archived by the owner on Jul 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
d3-timer-test.ts
39 lines (28 loc) · 1.59 KB
/
d3-timer-test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* Typescript definition tests for d3/d3-timer module
*
* Note: These tests are intended to test the definitions only
* in the sense of typing and call signature consistency. They
* are not intended as functional tests.
*/
import * as d3Timer from '../../src/d3-timer';
// Test now definition
let now: number = d3Timer.now();
// Test timer and timerFlush definitions ------------
let t0: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); });
let t1: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150);
let t2: d3Timer.Timer = d3Timer.timer((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.restart((elapsed: number) => { console.log(elapsed); });
t0.restart((elapsed: number) => { console.log(elapsed); }, 150);
t0.restart((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
t0.stop();
d3Timer.timerFlush();
t1.stop(); t2.stop();
// Test timeout Timer definitions --------------------------------
t0 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.timeout((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());
// Test interval Timer definitions --------------------------------
t0 = d3Timer.interval((elapsed: number) => { console.log(elapsed); });
t1 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150);
t2 = d3Timer.interval((elapsed: number) => { console.log(elapsed); }, 150, performance.now() || Date.now());