diff --git a/mockdate/index.d.ts b/mockdate/index.d.ts new file mode 100644 index 0000000000..ca97a79d75 --- /dev/null +++ b/mockdate/index.d.ts @@ -0,0 +1,18 @@ +// Type definitions for mockdate 2.0 +// Project: https://github.com/boblauer/MockDate +// Definitions by: Bruno Leonardo Michels +// 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; diff --git a/mockdate/mockdate-tests.ts b/mockdate/mockdate-tests.ts new file mode 100644 index 0000000000..e7854a6526 --- /dev/null +++ b/mockdate/mockdate-tests.ts @@ -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(); diff --git a/mockdate/tsconfig.json b/mockdate/tsconfig.json new file mode 100644 index 0000000000..9b92b9f946 --- /dev/null +++ b/mockdate/tsconfig.json @@ -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" + ] +} diff --git a/mockdate/tslint.json b/mockdate/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/mockdate/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }