From 75e598e6724989d14dfb933cdf1f93446740c234 Mon Sep 17 00:00:00 2001 From: P Christopher Bowers <41601975+pcbowers@users.noreply.github.com> Date: Mon, 29 Apr 2024 13:45:13 -0400 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=8F=B7=EF=B8=8F=20Use=20generic?= =?UTF-8?q?=20return=20type=20for=20all=20jest=20matchers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This better aligns with jest documentation: https://archive.jestjs.io/docs/en/23.x/expect#expectextendmatchers and ensures that types can work properly with other jest extension libraries like jest-chain. --- .../spectator/jest/src/lib/matchers-types.ts | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/projects/spectator/jest/src/lib/matchers-types.ts b/projects/spectator/jest/src/lib/matchers-types.ts index 6daa9c55..7afa788f 100644 --- a/projects/spectator/jest/src/lib/matchers-types.ts +++ b/projects/spectator/jest/src/lib/matchers-types.ts @@ -1,59 +1,59 @@ declare namespace jest { interface Matchers { - toExist(): boolean; + toExist(): R; - toHaveLength(expected: number): boolean; + toHaveLength(expected: number): R; - toHaveId(id: string | number): boolean; + toHaveId(id: string | number): R; - toHaveClass(className: string | string[], options?: { strict: boolean }): boolean; + toHaveClass(className: string | string[], options?: { strict: boolean }): R; - toHaveAttribute(attr: string | object, val?: string): boolean; + toHaveAttribute(attr: string | object, val?: string): R; - toHaveProperty(prop: string | object, val?: string | boolean): boolean; + toHaveProperty(prop: string | object, val?: string | boolean): R; - toContainProperty(prop: string | object, val?: string): boolean; + toContainProperty(prop: string | object, val?: string): R; - toHaveText(text: string | string[] | ((text: string) => boolean), exact?: boolean): boolean; + toHaveText(text: string | string[] | ((text: string) => boolean), exact?: boolean): R; - toContainText(text: string | string[] | ((text: string) => boolean), exact?: boolean): boolean; + toContainText(text: string | string[] | ((text: string) => boolean), exact?: boolean): R; - toHaveExactText(text: string | string[] | ((text: string) => boolean), options?: { trim: boolean }): boolean; + toHaveExactText(text: string | string[] | ((text: string) => boolean), options?: { trim: boolean }): R; - toHaveExactTrimmedText(text: string | string[] | ((text: string) => boolean)): boolean; + toHaveExactTrimmedText(text: string | string[] | ((text: string) => boolean)): R; - toHaveValue(value: string | string[]): boolean; + toHaveValue(value: string | string[]): R; - toContainValue(value: string | string[]): boolean; + toContainValue(value: string | string[]): R; - toHaveStyle(style: { [styleKey: string]: any }): boolean; + toHaveStyle(style: { [styleKey: string]: any }): R; - toHaveData({ data, val }: { data: string; val: string }): boolean; + toHaveData({ data, val }: { data: string; val: string }): R; - toBeChecked(): boolean; + toBeChecked(): R; - toBeIndeterminate(): boolean; + toBeIndeterminate(): R; - toBeDisabled(): boolean; + toBeDisabled(): R; - toBeEmpty(): boolean; + toBeEmpty(): R; - toBePartial(partial: object): boolean; + toBePartial(partial: object): R; - toBeHidden(): boolean; + toBeHidden(): R; - toBeSelected(): boolean; + toBeSelected(): R; - toBeVisible(): boolean; + toBeVisible(): R; - toBeFocused(): boolean; + toBeFocused(): R; - toBeMatchedBy(selector: string | Element): boolean; + toBeMatchedBy(selector: string | Element): R; - toHaveDescendant(selector: string | Element): boolean; + toHaveDescendant(selector: string | Element): R; - toHaveDescendantWithText({ selector, text }: { selector: string; text: string }): boolean; + toHaveDescendantWithText({ selector, text }: { selector: string; text: string }): R; - toHaveSelectedOptions(expected: string | string[] | HTMLOptionElement | HTMLOptionElement[]): boolean; + toHaveSelectedOptions(expected: string | string[] | HTMLOptionElement | HTMLOptionElement[]): R; } }