From 7a05f51b8d4078f5a20057550a4d0fcbcd0d2771 Mon Sep 17 00:00:00 2001 From: Gregor MacDougall Date: Fri, 27 Jan 2017 21:53:38 -0500 Subject: [PATCH] Correct Jest toBeCloseTo signature In Jest .toBeCloseTo's second parameter is optional with a default of 5. See: https://facebook.github.io/jest/docs/api.html#tobeclosetonumber-numdigits This updates the type definition to make this parameter optional as well. --- jest/index.d.ts | 2 +- jest/jest-tests.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jest/index.d.ts b/jest/index.d.ts index f376ea5bcc..cb25dcc758 100644 --- a/jest/index.d.ts +++ b/jest/index.d.ts @@ -117,7 +117,7 @@ declare namespace jest { toBe(expected: any): void; toBeCalled(): void; toBeCalledWith(...args: any[]): void; - toBeCloseTo(expected: number, delta: number): void; + toBeCloseTo(expected: number, delta?: number): void; toBeDefined(): void; toBeFalsy(): void; toBeGreaterThan(expected: number): void; diff --git a/jest/jest-tests.ts b/jest/jest-tests.ts index 913a671fa1..4f54d44236 100644 --- a/jest/jest-tests.ts +++ b/jest/jest-tests.ts @@ -147,6 +147,10 @@ describe('compartion', function () { it('works sanely with simple decimals', function () { expect(0.2 + 0.1).toBeCloseTo(0.3, 5); }); + + it('works sanely with simple decimals and the default delta', function () { + expect(0.2 + 0.1).toBeCloseTo(0.3); + }); }); describe('toThrow API', function () {