From e92bf375381c8e3b8717a2b714f303840856021c Mon Sep 17 00:00:00 2001 From: Rogier Schouten Date: Thu, 20 Aug 2015 10:56:30 +0200 Subject: [PATCH] Update Sinon typings for Sinon 1.16.0 Add setSystemTime() method --- sinon/sinon-tests.ts | 6 ++++++ sinon/sinon.d.ts | 17 +++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/sinon/sinon-tests.ts b/sinon/sinon-tests.ts index ca916788d..3e6f72086 100644 --- a/sinon/sinon-tests.ts +++ b/sinon/sinon-tests.ts @@ -109,3 +109,9 @@ testSix(); testSeven(); testEight(); testNine(); + +var clock: Sinon.SinonFakeTimers = sinon.useFakeTimers(); +clock.setSystemTime(1000); +clock.setSystemTime(new Date()); + + diff --git a/sinon/sinon.d.ts b/sinon/sinon.d.ts index 6440dda90..cdb316976 100644 --- a/sinon/sinon.d.ts +++ b/sinon/sinon.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Sinon 1.8.1 +// Type definitions for Sinon 1.16.0 // Project: http://sinonjs.org/ // Definitions by: William Sears // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -181,7 +181,20 @@ declare module Sinon { Date(year: number, month: number, day: number, hour: number, minute: number, second: number): Date; Date(year: number, month: number, day: number, hour: number, minute: number, second: number, ms: number): Date; restore(): void; - } + + /** + * Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp + * without affecting timers, intervals or immediates. + * @param now The new 'now' in unix milliseconds + */ + setSystemTime(now: number): void; + /** + * Simulate the user changing the system clock while your program is running. It changes the 'now' timestamp + * without affecting timers, intervals or immediates. + * @param now The new 'now' as a JavaScript Date + */ + setSystemTime(date: Date): void; + } interface SinonFakeTimersStatic { (): SinonFakeTimers;