Skip to content

Commit c66b17f

Browse files
committed
Add: toHaveStyle tests first approach
1 parent ec10ba5 commit c66b17f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

packages/dom/test/unit/lib/ElementAssertion.test.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AssertionError, expect } from "@assertive-ts/core";
2-
import { render } from "@testing-library/react";
2+
import { getByTestId, render } from "@testing-library/react";
33

44
import { ElementAssertion } from "../../../src/lib/ElementAssertion";
55

@@ -265,4 +265,17 @@ describe("[Unit] ElementAssertion.test.ts", () => {
265265
});
266266
});
267267

268-
});
268+
describe(".toHaveStyle", () => {
269+
context("when the element has the expected style when passed as object", () => {
270+
it("returns the assertion instance when it receives an object", () => {
271+
const { getByTestId } = render(<div className="foo bar test" style={{ display: "flex", color: "red" }} data-testid="test-div" />);
272+
const divTest = getByTestId("test-div");
273+
const test = new ElementAssertion(divTest);
274+
275+
expect(test.toHaveStyle("display: flex; color: red")).toBeEqual(test);
276+
277+
});
278+
});
279+
})
280+
281+
})

0 commit comments

Comments
 (0)