Skip to content

Commit 1487a94

Browse files
committed
Add anotations
1 parent 343d521 commit 1487a94

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

packages/dom/src/lib/ElementAssertion.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,17 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
9191
});
9292
}
9393

94+
/**
95+
* Check if the element has a specific class or classes.
96+
*
97+
* Validates that the provided element contains specified classes.
98+
* Allows checking for one or more class names and supports exact matching.
99+
*
100+
* @param classNames - A single class name or an array of class names to check.
101+
* @param options - Optional settings for matching:
102+
* - `exact` (boolean): When true, checks for an exact match of all classes.
103+
* @returns the assertion instance.
104+
*/
94105
public toHaveClass(classNames: string | string[], options: { exact?: boolean; } = {}): this {
95106
const actualClassList = this.actual.className.split(/\s+/).filter(Boolean);
96107
const expectedClassList = Array.isArray(classNames) ? classNames : [classNames];

0 commit comments

Comments
 (0)