Skip to content

Commit 5ba57a6

Browse files
committed
Add: Assertion execution
1 parent ab11999 commit 5ba57a6

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

packages/dom/src/lib/ElementAssertion.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,17 +239,20 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
239239
})
240240

241241
console.log("isSameStyle: ", isSameStyle)
242-
243-
return this.execute({
244-
assertWhen: true,
245-
error: new AssertionError({
242+
const error = new AssertionError({
246243
actual: this.actual,
247-
message: "Expected the element to have the specified style",
248-
}),
249-
invertedError: new AssertionError({
244+
message: `Expected the element to have ${JSON.stringify(expectedStyle)} style`,
245+
expected: expectedStyle
246+
})
247+
const invertedError = new AssertionError({
250248
actual: this.actual,
251-
message: "Expected the element to NOT have the specified style",
252-
}),
249+
message: `Expected the element to NOT have ${JSON.stringify(expectedStyle)} style`,
250+
})
251+
252+
return this.execute({
253+
assertWhen: isSameStyle,
254+
error,
255+
invertedError
253256
});
254257
}
255258
return this;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ describe("[Unit] ElementAssertion.test.ts", () => {
272272
const divTest = getByTestId("test-div");
273273
const test = new ElementAssertion(divTest);
274274

275-
expect(test.toHaveStyle("color: red; display: flex; border: 1px solid black")).toBeEqual(test);
275+
expect(test.toHaveStyle("display: flex; color: red; border: 1px solid black")).toBeEqual(test);
276276

277277
});
278278
it("fails the assertion when the styles are not the same", () => {

0 commit comments

Comments
 (0)