From d2dd0dbfc70f5bd50aab635156620b3a2578a48d Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Fri, 18 Dec 2015 05:09:35 +0100 Subject: [PATCH] Improve jasmine.d.ts - Remove toContainHtml() and toContainText(): they are not part of Jasmine API - Avoid the use of any for toMatch(), toBeLessThan(), toBeGreaterThan(), toBeCloseTo() and toThrowError() --- jasmine-jquery/jasmine-jquery.d.ts | 8 ++++---- jasmine/jasmine.d.ts | 13 ++++++------- knockout/tests/jasmine.extensions.d.ts | 10 ++++++++++ .../tests/knockout-templatingBehaviors-tests.ts | 1 + 4 files changed, 21 insertions(+), 11 deletions(-) create mode 100644 knockout/tests/jasmine.extensions.d.ts diff --git a/jasmine-jquery/jasmine-jquery.d.ts b/jasmine-jquery/jasmine-jquery.d.ts index 903e3f7e2..0e1f2b82b 100644 --- a/jasmine-jquery/jasmine-jquery.d.ts +++ b/jasmine-jquery/jasmine-jquery.d.ts @@ -195,8 +195,8 @@ declare module jasmine { * // returns true * expect($('

header

')).toContainHtml('') */ - //toContainHtml(html: string): boolean; - + toContainHtml(html: string): boolean; + /** * Check if DOM element has the given Text. * @param text Accepts a string or regular expression @@ -213,8 +213,8 @@ declare module jasmine { * // returns true * expect($('

header

')).toContainText('header') */ - //toContainText(text: string): boolean; - + toContainText(text: string): boolean; + /** * Check if DOM element has the given value. * This can only be applied for element on with jQuery val() can be called. diff --git a/jasmine/jasmine.d.ts b/jasmine/jasmine.d.ts index ed8591488..46a1937f4 100644 --- a/jasmine/jasmine.d.ts +++ b/jasmine/jasmine.d.ts @@ -281,7 +281,7 @@ declare module jasmine { toBe(expected: any, expectationFailOutput?: any): boolean; toEqual(expected: any, expectationFailOutput?: any): boolean; - toMatch(expected: any, expectationFailOutput?: any): boolean; + toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; toBeDefined(expectationFailOutput?: any): boolean; toBeUndefined(expectationFailOutput?: any): boolean; toBeNull(expectationFailOutput?: any): boolean; @@ -291,13 +291,12 @@ declare module jasmine { toHaveBeenCalled(): boolean; toHaveBeenCalledWith(...params: any[]): boolean; toContain(expected: any, expectationFailOutput?: any): boolean; - toBeLessThan(expected: any, expectationFailOutput?: any): boolean; - toBeGreaterThan(expected: any, expectationFailOutput?: any): boolean; - toBeCloseTo(expected: any, precision: any, expectationFailOutput?: any): boolean; - toContainHtml(expected: string): boolean; - toContainText(expected: string): boolean; + toBeLessThan(expected: number, expectationFailOutput?: any): boolean; + toBeGreaterThan(expected: number, expectationFailOutput?: any): boolean; + toBeCloseTo(expected: number, precision: any, expectationFailOutput?: any): boolean; toThrow(expected?: any): boolean; - toThrowError(expected?: any, message?: string): boolean; + toThrowError(message?: string | RegExp): boolean; + toThrowError(expected?: Error, message?: string | RegExp): boolean; not: Matchers; Any: Any; diff --git a/knockout/tests/jasmine.extensions.d.ts b/knockout/tests/jasmine.extensions.d.ts new file mode 100644 index 000000000..c3b12213f --- /dev/null +++ b/knockout/tests/jasmine.extensions.d.ts @@ -0,0 +1,10 @@ +// Knockout specs depend on custom Jasmine matchers +// See https://github.com/knockout/knockout/blob/v3.4.0/spec/lib/jasmine.extensions.js +// FYI jasmine-jquery.d.ts (https://github.com/velesin/jasmine-jquery) also defines toContainHtml() and toContainText() + +declare module jasmine { + interface Matchers { + toContainHtml(expected: string): boolean; + toContainText(expected: string): boolean; + } +} diff --git a/knockout/tests/knockout-templatingBehaviors-tests.ts b/knockout/tests/knockout-templatingBehaviors-tests.ts index 50ec27572..cd86465b2 100644 --- a/knockout/tests/knockout-templatingBehaviors-tests.ts +++ b/knockout/tests/knockout-templatingBehaviors-tests.ts @@ -1,4 +1,5 @@ /// +/// /// ///