sf-time-mock
Mock utility for a function returning a timestamp (like Date.now()).
Usage
var initTimeMock = ; // Init the time mockvar timeStub = ; // Set the current timetimeStub; // Use it everywhere;// '2010-03-06T00:00:00.000Z'
function
initTimeMock() ⇒ Spawn a new time stub
Kind: global function
Returns: function
- A time stub
- initTimeMock() ⇒
function
- ~timeStub() ⇒
Number
- .setTime(value, n) ⇒
void
- .reset() ⇒
void
- .ended() ⇒
Boolean
- .setTimes(theTimes) ⇒
void
- .appendTimes(theTimes) ⇒
void
- .setTime(value, n) ⇒
- ~timeStub() ⇒
Number
initTimeMock~timeStub() ⇒ Return the next timestamp
Kind: inner method of initTimeMock
Returns: Number
- The next mocked timestamp
Throws:
YError
E_TIME_ENDED exception when no timestamp available
- ~timeStub() ⇒
Number
- .setTime(value, n) ⇒
void
- .reset() ⇒
void
- .ended() ⇒
Boolean
- .setTimes(theTimes) ⇒
void
- .appendTimes(theTimes) ⇒
void
- .setTime(value, n) ⇒
void
timeStub.setTime(value, n) ⇒ Set a timestamp for the n next calls
Kind: static method of timeStub
Param | Type | Description |
---|---|---|
value | Number |
The timestamp value |
n | Number |
The number of call it should be used. Default to Infinity. |
void
timeStub.reset() ⇒ Reset the time stub
Kind: static method of timeStub
Boolean
timeStub.ended() ⇒ Say if there is no more timestamp available
Kind: static method of timeStub
Returns: Boolean
- A boolean indicating if it ended or not
void
timeStub.setTimes(theTimes) ⇒ Set a bunch of timestamp to the queue
Kind: static method of timeStub
Param | Type | Description |
---|---|---|
theTimes | Array |
An array of timestamps or timestamp objects (format: {value, n}). |
void
timeStub.appendTimes(theTimes) ⇒ Add a bunch of timestamps to the queue
Kind: static method of timeStub
Param | Type | Description |
---|---|---|
theTimes | Array |
An array of timestamps or timestamp objects (format: {value, n}). |