Skip to content

Commit 8c2f5f7

Browse files
committed
Add: getReceivedStyle function enhanced
1 parent 3f15075 commit 8c2f5f7

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

packages/dom/src/lib/ElementAssertion.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
217217
}
218218

219219
/**
220-
* Asserts that the element has one or more of the specified CSS style.
220+
* Asserts that the element has one or more of the specified CSS styles.
221221
*
222222
* @example
223223
* ```
@@ -230,15 +230,16 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
230230

231231
public toHaveSomeStyle(expected: Partial<CSSStyleDeclaration>): this {
232232

233-
const [expectedStyle, receivedStyle] = getExpectedAndReceivedStyles(this.actual, expected);
233+
const [expectedStyle, elementProcessedStyle] = getExpectedAndReceivedStyles(this.actual, expected);
234234

235-
if (!expectedStyle || !receivedStyle) {
235+
if (!expectedStyle || !elementProcessedStyle) {
236236
throw new Error("No available styles.");
237237
}
238238

239-
const hasSomeStyle = Object.values(receivedStyle).some((receivedItem, idx) => {
240-
const expectedItem = Object.values(expectedStyle)[idx];
241-
return equal(expectedItem, receivedItem);
239+
const hasSomeStyle = Object.entries(expectedStyle).some(([expectedProp, expectedValue]) => {
240+
return Object.entries(elementProcessedStyle).some(([receivedProp, receivedValue]) => {
241+
return equal(expectedProp, receivedProp) && equal(expectedValue, receivedValue);
242+
});
242243
});
243244

244245
const error = new AssertionError({

0 commit comments

Comments
 (0)