Skip to content

Commit 0f6ffc9

Browse files
committed
[IMP] test: improve expect.toHaveStyle jest matcher
Improve the `expect.toHaveStyle` jest matcher to normalize colors to hex format. Task: 5059476 X-original-commit: 13482ee Part-of: #7177 Signed-off-by: Pierre Rousseau (pro) <pro@odoo.com>
1 parent 8cc543d commit 0f6ffc9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tests/setup/jest_extend.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Model } from "../../src";
2-
import { isSameColor } from "../../src/helpers/color";
2+
import { isSameColor, toHex } from "../../src/helpers/color";
33
import { toXC } from "../../src/helpers/coordinates";
44
import { deepEquals } from "../../src/helpers/misc";
55
import { positions } from "../../src/helpers/zones";
@@ -308,6 +308,9 @@ CancelledReasons: ${this.utils.printReceived(dispatchResult.reasons)}
308308
const receivedStyle: Record<string, string> = {};
309309
for (const key of Object.keys(expectedStyle)) {
310310
receivedStyle[key] = element.style.getPropertyValue(key);
311+
if (receivedStyle[key].startsWith("rgb")) {
312+
receivedStyle[key] = toHex(receivedStyle[key]);
313+
}
311314
}
312315
const pass = this.equals(receivedStyle, expectedStyle, [this.utils.iterableEquality]);
313316
const message = () =>

0 commit comments

Comments
 (0)