mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Add definitions for mockdate package (#13754)
* Add mockdate package definition file * Fix mockdate comments * Apply revision checks on mockdate Add tslint.json Enable strciNullChecks Change definition to export functions intead of default. * Fix mockdate to export as namespace
This commit is contained in:
parent
fc5b949e78
commit
a1cbc2a5dc
18
mockdate/index.d.ts
vendored
Normal file
18
mockdate/index.d.ts
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
// Type definitions for mockdate 2.0
|
||||
// Project: https://github.com/boblauer/MockDate
|
||||
// Definitions by: Bruno Leonardo Michels <https://github.com/brunolm>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export as namespace MockDate;
|
||||
|
||||
/**
|
||||
* Change the Date implementation to mock a specific date.
|
||||
* @param Date to be set as current
|
||||
* @param timezoneOffset? The value that should be returned by new Date().getTimezoneOffset()
|
||||
*/
|
||||
export function set(date: { valueOf(): number; } | number | string, timezoneOffset?: number): void;
|
||||
|
||||
/**
|
||||
* Restore the original Date object back to the native implementation.
|
||||
*/
|
||||
export function reset(): void;
|
||||
9
mockdate/mockdate-tests.ts
Normal file
9
mockdate/mockdate-tests.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import * as mockdate from 'mockdate';
|
||||
|
||||
mockdate.set(new Date());
|
||||
mockdate.set('2017-01-05');
|
||||
mockdate.set(new Date().getTime());
|
||||
|
||||
mockdate.set(new Date(), 0);
|
||||
|
||||
mockdate.reset();
|
||||
20
mockdate/tsconfig.json
Normal file
20
mockdate/tsconfig.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"mockdate-tests.ts"
|
||||
]
|
||||
}
|
||||
1
mockdate/tslint.json
Normal file
1
mockdate/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Loading…
Reference in New Issue
Block a user