UNPKG

@skyux-sdk/testing

Version:

This library was generated with [Nx](https://nx.dev).

156 lines (155 loc) 8.97 kB
import { SkyA11yAnalyzerConfig } from '../a11y/a11y-analyzer-config'; import { SkyToBeVisibleOptions } from './to-be-visible-options'; /** * Interface for "asynchronous" custom Sky matchers which cannot be paired with a `.not` operator. */ export interface SkyAsyncMatchers<T, U> extends jasmine.AsyncMatchers<T, U> { /** * Invert the matcher following this `expect` */ not: SkyAsyncMatchers<T, U>; /** * `expect` an element to be accessible based on Web Content Accessibility * Guidelines 2.0 (WCAG20) Level A and AA success criteria. * @param config The configuration settings for overwriting or turning off specific accessibility checks. * @see https://developer.blackbaud.com/skyux/learn/get-started/advanced/accessibility-unit-tests */ toBeAccessible(config?: SkyA11yAnalyzerConfig): Promise<jasmine.CustomMatcherResult>; /** * `expect` the actual text to equal the text for the expected resource string. * Uses `SkyAppResourcesService.getString(name, args)` to fetch the expected resource string * and compares using ===. * @param name The resource string to fetch from the resource file and compare against. * @param args The string replacement arguments for the expected resource string. */ toEqualResourceText(name: string, args?: any[]): Promise<jasmine.CustomMatcherResult>; /** * `expect` the actual text to equal the text for the expected resource string. * Uses `SkyLibResourcesService.getString(name, args)` to fetch the expected resource string * and compares using ===. * @param name The resource string to fetch from the resource file and compare against. * @param args The string replacement arguments for the expected resource string. */ toEqualLibResourceText(name: string, args?: any[]): Promise<jasmine.CustomMatcherResult>; /** * `expect` the actual element to have the text for the expected resource string. * Uses `SkyAppResourcesService.getString(name, args)` to fetch the expected resource string * and compares using ===. * @param name The resource string to fetch from the resource file and compare against. * @param args The string replacement arguments for the expected resource string. * @param trimWhitespace [true] Whether or not to trim whitespace from the actual element text before comparison. */ toHaveResourceText(name: string, args?: any[], trimWhitespace?: boolean): Promise<jasmine.CustomMatcherResult>; /** * `expect` the actual element to have the text for the expected resource string. * Uses `SkyLibResourcesService.getString(name, args)` to fetch the expected resource string * and compares using ===. * @param name The resource string to fetch from the resource file and compare against. * @param args The string replacement arguments for the expected resource string. * @param trimWhitespace [true] Whether or not to trim whitespace from the actual element text before comparison. */ toHaveLibResourceText(name: string, args?: any[], trimWhitespace?: boolean): Promise<jasmine.CustomMatcherResult>; /** * `expect` the actual element to have the text for the expected resource string. * Uses `SkyAppResourcesService.getString(name, args)` to fetch the expected resource string * and compares the tokenized element text against the template. * Essentially this matches any text that has the non-parameterized text of the template in the order of the template, * regardless of the value of each of the parameters. * @param name The resource string to fetch from the resource file and compare against. */ toMatchResourceTemplate(name: string): Promise<jasmine.CustomMatcherResult>; /** * `expect` the actual element to have the text for the expected resource string. * Uses `SkyLibResourcesService.getString(name, args)` to fetch the expected resource string * and compares the tokenized element text against the template. * Essentially this matches any text that has the non-parameterized text of the template in the order of the template, * regardless of the value of each of the parameters. * @param name The resource string to fetch from the resource file and compare against. */ toMatchLibResourceTemplate(name: string): Promise<jasmine.CustomMatcherResult>; } /** * Interface for "normal" custom Sky matchers (includes original jasmine matchers). */ export interface SkyMatchers<T> extends jasmine.Matchers<T> { /** * Invert the matcher following this `expect` */ not: SkyMatchers<T>; /** * `expect` the actual element to be visible. * Checks elements style display and visibility and bounding box width/height. */ toBeVisible(options?: SkyToBeVisibleOptions): void; /** * `expect` the actual element to exist. */ toExist(): void; /** * `expect` the actual element to have the expected css class. * @param expectedClassName The css class name to check for. */ toHaveCssClass(expectedClassName: string): void; /** * `expect` the actual element to have the expected style(s). * @param expectedStyles An object representing the style(s) to check for. */ toHaveStyle(expectedStyles: Record<string, string>): void; /** * `expect` the actual element to have the expected text. * @param expectedText The text to check for in the actual element. * @param trimWhitespace [true] Whether or not to trim whitespace from the actual element text before comparison. */ toHaveText(expectedText: string, trimWhitespace?: boolean): void; /** * `expect` the actual component to be accessible based on Web Content Accessibility * Guidelines 2.0 (WCAG20) Level A and AA success criteria. * @deprecated Use `await expectAsync(element).toBeAccessible()` instead. * @param callback The callback to execute after accessibility checks run. * @param config The configuration settings for overwriting or turning off specific accessibility checks. * @see https://developer.blackbaud.com/skyux/learn/get-started/advanced/accessibility-unit-tests */ toBeAccessible(callback?: () => void, config?: SkyA11yAnalyzerConfig): void; /** * `expect` the actual text to equal the text for the expected resource string. * Uses `SkyAppResourcesService.getString(name, args)` to fetch the expected resource string * and compares using ===. * @deprecated Use `await expectAsync('Some message.').toEqualResourceText('foo_bar_key')` instead. * @param name The resource string to fetch from the resource file and compare against. * @param args The string replacement arguments for the expected resource string. * @param callback The callback to execute when the comparison fails. */ toEqualResourceText(name: string, args?: any[], callback?: () => void): void; /** * `expect` the actual element to have the text for the expected resource string. * Uses `SkyAppResourcesService.getString(name, args)` to fetch the expected resource string * and compares using ===. * @deprecated Use `await expectAsync(element).toHaveResourceText('foo_bar_key')` instead. * @param name The resource string to fetch from the resource file and compare against. * @param args The string replacement arguments for the expected resource string. * @param trimWhitespace [true] Whether or not to trim whitespace from the actual element text before comparison. * @param callback The callback to execute when the comparison fails. */ toHaveResourceText(name: string, args?: any[], trimWhitespace?: boolean, callback?: () => void): void; /** * `expect` the actual element to have the text for the expected resource string. * Uses `SkyAppResourcesService.getString(name, args)` to fetch the expected resource string * and compares the tokenized element text against the template. * Essentially this matches any text that has the non-parameterized text of the template in the order of the template, * regardless of the value of each of the parameters. * @deprecated Use `await expectAsync(element).toMatchResourceTemplate('foo_bar_key')` instead. * @param name The resource string to fetch from the resource file and compare against. * @param callback The callback to execute when the comparison fails. */ toMatchResourceTemplate(name: string, callback?: () => void): void; } /** * Create an expectation for a spec. * @param actual Actual computed value to test expectations against. */ export declare function expect<T>(actual: T): SkyMatchers<T>; /** * Create an async expectation for a spec. * @param actual Actual computed value to test expectations against. */ export declare function expectAsync<T, U>(actual: T | PromiseLike<T>): SkyAsyncMatchers<T, U>;