Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jest defs for dom testing library #2849

Merged
merged 1 commit into from Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions definitions/npm/jest_v23.x.x/flow_v0.39.x-/jest_v23.x.x.js
Expand Up @@ -205,9 +205,19 @@ type EnzymeMatchersType = {

// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers
type DomTestingLibraryType = {
toBeDisabled(): void,
toBeEmpty(): void,
toBeInTheDocument(): void,
toBeVisible(): void,
toContainElement(element: HTMLElement | null): void,
toContainHTML(htmlText: string): void,
toHaveAttribute(name: string, expectedValue?: string): void,
toHaveClass(...classNames: string[]): void,
toHaveFocus(): void,
toHaveFormValues(expectedValues: { [name: string]: any }): void,
toHaveStyle(css: string): void,
toHaveTextContent(content: string | RegExp, options?: { normalizeWhitespace: boolean }): void,
toBeInTheDOM(): void,
toHaveTextContent(content: string): void,
toHaveAttribute(name: string, expectedValue?: string): void
};

// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers
Expand Down
35 changes: 27 additions & 8 deletions definitions/npm/jest_v23.x.x/flow_v0.39.x-/test_jest-v23.x.x.js
Expand Up @@ -488,14 +488,16 @@ expect(wrapper).toHaveDisplayName(true);
{
const element = document.createElement('div');

expect(element).toHaveTextContent('123');
// $ExpectError: expected text content should be present
expect(element).toHaveTextContent();
// $ExpectError: expected text content should be a string
expect(element).toHaveTextContent(1);

expect(element).toBeInTheDOM();

expect(element).toBeDisabled();
expect(element).toBeEmpty();
expect(element).toBeInTheDocument();
expect(element).toBeVisible();
// $ExpectError
expect(element).toContainElement();
expect(element).toContainElement(element);
// $ExpectError
expect(element).toContainHTML();
expect(element).toContainHTML('<div></div>');
expect(element).toHaveAttribute('foo');
expect(element).toHaveAttribute('foo', 'bar');
// $ExpectError: attribute name should be present
Expand All @@ -504,6 +506,23 @@ expect(wrapper).toHaveDisplayName(true);
expect(element).toHaveAttribute(1);
// $ExpectError: expected attribute value should be a string
expect(element).toHaveAttribute('foo', 1);
// $ExpectError
expect(element).toHaveClass(1);
expect(element).toHaveClass('foo');
expect(element).toHaveFocus();
// $ExpectError
expect(element).toHaveFormValues();
expect(element).toHaveFormValues({ foo: 'bar' });
// $ExpectError
expect(element).toHaveStyle();
expect(element).toHaveStyle('foo');
expect(element).toHaveTextContent('123');
// $ExpectError: expected text content should be present
expect(element).toHaveTextContent();
// $ExpectError: expected text content should be a string
expect(element).toHaveTextContent(1);

expect(element).toBeInTheDOM();
}

{
Expand Down