Skip to content

Commit 496e5e7

Browse files
committed
Add: example to matcher and refactored JSDoc across class
1 parent 2fc9de4 commit 496e5e7

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

packages/dom/src/lib/ElementAssertion.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
6060
/**
6161
* Check if the element has a specific attribute.
6262
*
63-
* @param name - The attribute name.
64-
* @param expectedValue - The expected attribute value (Optional).
63+
* @param name the attribute name.
64+
* @param expectedValue the expected attribute value (Optional).
6565
* @returns the assertion instance.
6666
*/
6767
public toHaveAttribute(name: string, expectedValue?: string): this {
@@ -97,7 +97,7 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
9797
/**
9898
* Asserts that the element has the specified class.
9999
*
100-
* @param className The class name to check.
100+
* @param className the class name to check.
101101
* @returns the assertion instance.
102102
*/
103103
public toHaveClass(className: string): this {
@@ -131,7 +131,7 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
131131
/**
132132
* Asserts that the element has all of the specified classes.
133133
*
134-
* @param classNames - A variadic list of class names to check.
134+
* @param classNames a variadic list of class names to check.
135135
* @returns the assertion instance.
136136
*/
137137
public toHaveAllClasses(...classNames: string[]): this {
@@ -148,13 +148,17 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
148148
/**
149149
* Asserts that the element has the specified CSS styles.
150150
*
151-
* @param expected - The expected CSS styles.
152-
* @returns The assertion instance.
151+
* @example
152+
* ```
153+
* expect(component).toHaveStyle({ color: 'green', display: 'block' });
154+
* ```
155+
*
156+
* @param expected the expected CSS styles.
157+
* @returns the assertion instance.
153158
*/
154-
155159
public toHaveStyle(expected: Partial<CSSStyleDeclaration>): this {
156160
if (!this.actual.ownerDocument.defaultView) {
157-
throw new Error("The element is not attached to a document with a default view.");
161+
throw new Error("The element does not contain default view property.");
158162
}
159163
if (!(this.actual instanceof HTMLElement)) {
160164
throw new Error("The element is not an HTMLElement.");
@@ -188,10 +192,10 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
188192
/**
189193
* Helper method to assert the presence or absence of class names.
190194
*
191-
* @param assertCondition - Boolean to determine assertion pass or fail.
192-
* @param classNames - Array of class names involved in the assertion.
193-
* @param message - Assertion error message.
194-
* @param invertedMessage - Inverted assertion error message.
195+
* @param assertCondition boolean to determine assertion pass or fail.
196+
* @param classNames array of class names involved in the assertion.
197+
* @param message assertion error message.
198+
* @param invertedMessage inverted assertion error message.
195199
* @returns the assertion instance.
196200
*/
197201
private assertClassPresence(

0 commit comments

Comments
 (0)