From 7ae2eba53391edc454d0f75a2f04ad7db5475434 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 21 Jan 2018 19:29:28 -0800 Subject: [PATCH 1/7] Allowed functions in jest's describe As of 22.0.5, jest allows classes for describe blocks. --- types/jest/index.d.ts | 2 +- types/jest/jest-tests.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 0ba1762485..669a96fa23 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -220,7 +220,7 @@ declare namespace jest { } interface Describe { - (name: string, fn: EmptyFunction): void; + (name: string | Function, fn: EmptyFunction): void; only: Describe; skip: Describe; } diff --git a/types/jest/jest-tests.ts b/types/jest/jest-tests.ts index 4d8ae05e1c..146c848a72 100644 --- a/types/jest/jest-tests.ts +++ b/types/jest/jest-tests.ts @@ -10,6 +10,10 @@ declare const $: any; // Tests based on the Jest website jest.unmock('../sum'); +class TestClass { } + +describe(TestClass, () => { }); + describe('sum', () => { it('adds 1 + 2 to equal 3', () => { const sum: (a: number, b: number) => number = require('../sum'); From 983acb16764911e46947688579d0e5129c737a11 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 21 Jan 2018 19:33:28 -0800 Subject: [PATCH 2/7] Bumped jest version in types to 22.0.5 --- types/jest/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 669a96fa23..218eef8457 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Jest 22.0 +// Type definitions for Jest 22.0.5 // Project: http://facebook.github.io/jest/ // Definitions by: Asana // Ivo Stratev From 4b3b60fd821a294f33abf5095a4dca0b68b54c4e Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sun, 21 Jan 2018 22:05:01 -0800 Subject: [PATCH 3/7] Used a ClassLike interface because of ban-types --- types/jest/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 218eef8457..ba36a036d6 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -199,6 +199,10 @@ declare namespace jest { type Lifecycle = (fn: ProvidesCallback, timeout?: number) => any; + interface IClassLike { + readonly name: string; + } + /** * Creates a test closure */ @@ -220,7 +224,7 @@ declare namespace jest { } interface Describe { - (name: string | Function, fn: EmptyFunction): void; + (name: number | string | IClassLike, fn: EmptyFunction): void; only: Describe; skip: Describe; } From b47fc25da9455080fd29806247a38b8b27fb9cfe Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 7 Feb 2018 16:36:08 -0800 Subject: [PATCH 4/7] Renamed to FunctionLike; allowed Function --- types/jest/index.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index ba36a036d6..2d67c8fa97 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -199,7 +199,7 @@ declare namespace jest { type Lifecycle = (fn: ProvidesCallback, timeout?: number) => any; - interface IClassLike { + interface FunctionLike { readonly name: string; } @@ -224,7 +224,8 @@ declare namespace jest { } interface Describe { - (name: number | string | IClassLike, fn: EmptyFunction): void; + // tslint:disable-next-line ban-types + (name: number | string | Function | FunctionLike, fn: EmptyFunction): void; only: Describe; skip: Describe; } From 4e7c1db217790ca5aacf9851c64663b85aaf3a7f Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Wed, 7 Feb 2018 16:36:59 -0800 Subject: [PATCH 5/7] Added my name there too; why not? --- types/jest/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 2d67c8fa97..f58540fbe2 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -10,6 +10,7 @@ // Waseem Dahman // Jamie Mason // Douglas Duteil +// Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 8ca6f5823266871d7f49395396044e04812e8a2e Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 17 Mar 2018 08:12:36 -0700 Subject: [PATCH 6/7] Re-add TS comment and beforeAll --- types/jest/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 43768c629b..795ccb4739 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -13,7 +13,9 @@ // Ahn // Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +-// TypeScript Version: 2.3 +declare var beforeAll: jest.Lifecycle; declare var beforeEach: jest.Lifecycle; declare var afterAll: jest.Lifecycle; declare var afterEach: jest.Lifecycle; From c631d2f60d1a093da6140d034d6e862e8309067d Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Sat, 17 Mar 2018 08:12:58 -0700 Subject: [PATCH 7/7] Update index.d.ts --- types/jest/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/jest/index.d.ts b/types/jest/index.d.ts index 795ccb4739..70e9d6328b 100644 --- a/types/jest/index.d.ts +++ b/types/jest/index.d.ts @@ -13,7 +13,7 @@ // Ahn // Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped --// TypeScript Version: 2.3 +// TypeScript Version: 2.3 declare var beforeAll: jest.Lifecycle; declare var beforeEach: jest.Lifecycle;