From 2209c748eaa659374f07c23cdd66fe51f5cf6c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Spie=C3=9F?= Date: Wed, 16 Aug 2017 17:03:01 +0200 Subject: [PATCH 1/3] =?UTF-8?q?Fix=20definitions=20of=20=E2=80=9Cthrow?= =?UTF-8?q?=E2=80=9D=20and=20=E2=80=9CthrowError=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/should/index.d.ts | 4 ++-- types/should/should-tests.ts | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/types/should/index.d.ts b/types/should/index.d.ts index 0a5038d027..f7a192cf0e 100644 --- a/types/should/index.d.ts +++ b/types/should/index.d.ts @@ -91,7 +91,7 @@ interface ShouldAssertion { enumerables(...properties: string[]): ShouldAssertion; startWith(expected: string, message?: any): ShouldAssertion; endWith(expected: string, message?: any): ShouldAssertion; - throw(message?: any): ShouldAssertion; + throw(message?: any, properties?: Object): ShouldAssertion; //promises eventually: ShouldAssertion; @@ -137,7 +137,7 @@ interface ShouldAssertion { deepEqual(expected: any, description?: string): ShouldAssertion; exactly(expected: any, description?: string): ShouldAssertion; instanceOf(constructor: Function, description?: string): ShouldAssertion; - throwError(message?: any): ShouldAssertion; + throwError(message?: any, properties?: Object): ShouldAssertion; lengthOf(n: number, description?: string): ShouldAssertion; key(key: string): ShouldAssertion; hasOwnProperty(name: string, description?: string): ShouldAssertion; diff --git a/types/should/should-tests.ts b/types/should/should-tests.ts index 4b4b7146b7..fc5ae922b0 100644 --- a/types/should/should-tests.ts +++ b/types/should/should-tests.ts @@ -243,6 +243,18 @@ spy.should.have.threw("ReferenceError"); throw new Error('failed to foo'); }).should.throw(/^fail/); +(function () { + throw new Error('failed to foo'); +}).should.throw(Error); + +(function () { + throw new Error('failed to foo'); +}).should.throw(Error, { message: 'failed to baz' }); + +(function () { + throw new Error('failed to foo'); +}).should.throwError(Error, { message: 'failed to baz' }); + (function () { throw new Error('failed to baz'); }).should.throwError(/^fail.*/); From f536cc503eeb49857be87d74d93ccec7d7888d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Spie=C3=9F?= Date: Wed, 16 Aug 2017 17:03:21 +0200 Subject: [PATCH 2/3] Update should.js types for version 11 --- types/should/index.d.ts | 6 ++++-- types/should/should-tests.ts | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/types/should/index.d.ts b/types/should/index.d.ts index f7a192cf0e..041e8ee7b2 100644 --- a/types/should/index.d.ts +++ b/types/should/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for should.js v8.3.0 +// Type definitions for should.js v11.2.0 // Project: https://github.com/shouldjs/should.js -// Definitions by: Alex Varju , Maxime LUCE +// Definitions by: Alex Varju , Maxime LUCE , Lukas Spieß // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface Object { @@ -88,6 +88,8 @@ interface ShouldAssertion { keys(...allKeys: string[]): ShouldAssertion; keys(allKeys: string[]): ShouldAssertion; enumerable(property: string, value?: any): ShouldAssertion; + size(size: number): ShouldAssertion; + value(key: string | number, value: any): ShouldAssertion; enumerables(...properties: string[]): ShouldAssertion; startWith(expected: string, message?: any): ShouldAssertion; endWith(expected: string, message?: any): ShouldAssertion; diff --git a/types/should/should-tests.ts b/types/should/should-tests.ts index fc5ae922b0..9f894233bd 100644 --- a/types/should/should-tests.ts +++ b/types/should/should-tests.ts @@ -264,6 +264,11 @@ obj.should.have.keys('foo', 'bar'); obj.should.have.keys(['foo', 'bar']); obj.should.have.key('foo'); +({ a: 10 }).should.have.size(1); + +({ a: 10 }).should.have.value('a', 10); +({ a: 10 }).should.have.value(1, 2); + ({ a: 10 }).should.have.enumerable('a'); ({ a: 10 }).should.have.enumerable('a', 10); ({ a: 10, b: 10 }).should.have.enumerables('a', 'b'); From b68cc4ec54c8740a33be8f4f55be7e09c7653d35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Spie=C3=9F?= Date: Fri, 18 Aug 2017 02:07:16 +0200 Subject: [PATCH 3/3] =?UTF-8?q?Use=20=E2=80=9C{}=E2=80=9D=20type=20in=20ap?= =?UTF-8?q?propriate=20places?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- types/should/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/types/should/index.d.ts b/types/should/index.d.ts index 041e8ee7b2..96584bfe96 100644 --- a/types/should/index.d.ts +++ b/types/should/index.d.ts @@ -93,7 +93,7 @@ interface ShouldAssertion { enumerables(...properties: string[]): ShouldAssertion; startWith(expected: string, message?: any): ShouldAssertion; endWith(expected: string, message?: any): ShouldAssertion; - throw(message?: any, properties?: Object): ShouldAssertion; + throw(message?: any, properties?: {}): ShouldAssertion; //promises eventually: ShouldAssertion; @@ -101,7 +101,7 @@ interface ShouldAssertion { fulfilled(): Promise; fulfilledWith(value: any): Promise rejected(): Promise; - rejectedWith(message: (string | Function | RegExp), properties?: Object): Promise; + rejectedWith(message: (string | Function | RegExp), properties?: {}): Promise; rejectedWith(errType: Object): Promise; //http @@ -139,7 +139,7 @@ interface ShouldAssertion { deepEqual(expected: any, description?: string): ShouldAssertion; exactly(expected: any, description?: string): ShouldAssertion; instanceOf(constructor: Function, description?: string): ShouldAssertion; - throwError(message?: any, properties?: Object): ShouldAssertion; + throwError(message?: any, properties?: {}): ShouldAssertion; lengthOf(n: number, description?: string): ShouldAssertion; key(key: string): ShouldAssertion; hasOwnProperty(name: string, description?: string): ShouldAssertion;