From d7f6e54c62affd4ede49dbb521e719b9babfa421 Mon Sep 17 00:00:00 2001 From: Yishai Zehavi Date: Thu, 8 Nov 2018 12:51:02 +0200 Subject: [PATCH] Updated tests --- types/lolex/lolex-tests.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/types/lolex/lolex-tests.ts b/types/lolex/lolex-tests.ts index 56505c62e9..7137ba261d 100644 --- a/types/lolex/lolex-tests.ts +++ b/types/lolex/lolex-tests.ts @@ -28,7 +28,10 @@ lolex.createClock(new Date()); lolex.createClock(7, 9001); lolex.createClock(new Date(), 9001); -const installedClock = lolex.install({ +// showing two ways to specify the exact clock type for `install()` method: + +// first way: passing the exact clock type to `install()`. +const browserInstalledClock = lolex.install({ advanceTimeDelta: 20, loopLimit: 10, now: 0, @@ -37,7 +40,8 @@ const installedClock = lolex.install({ toFake: ["setTimeout", "nextTick", "hrtime"] }); -lolex.install({ +// second way: specify type for the clock variable as InstallClock. +const nodeInstalledClock: lolex.InstalledClock = lolex.install({ advanceTimeDelta: 20, loopLimit: 10, now: new Date(0), @@ -121,7 +125,11 @@ let [secs, nanos] = nodeClock.hrtime([0, 0]); secs.toFixed(); nanos.toExponential(); -installedClock.uninstall(); +browserInstalledClock.performance.now(); +nodeInstalledClock.nextTick(() => {}); + +browserInstalledClock.uninstall(); +nodeInstalledClock.uninstall(); // Clocks should be typed to have unbound method signatures that can be passed around const { clearTimeout } = browserClock;