Skip to content

Commit 03e9e4a

Browse files
committed
Fix linting errors
1 parent fa900c9 commit 03e9e4a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/dom/src/lib/ElementAssertion.ts

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

94-
public toHaveClass(classNames: string | string[], options: { exact?: boolean } = {}): this {
94+
public toHaveClass(classNames: string | string[], options: { exact?: boolean; } = {}): this {
9595
const actualClassList = this.actual.className.split(/\s+/).filter(Boolean);
9696
const expectedClassList = Array.isArray(classNames) ? classNames : [classNames];
9797
const { exact = false } = options;
@@ -100,20 +100,21 @@ export class ElementAssertion<T extends Element> extends Assertion<T> {
100100
actual: actualClassList,
101101
expected: expectedClassList,
102102
message: exact
103-
? `Expected the element to have exactly these classes: "${expectedClassList.join(' ')}"`
104-
: `Expected the element to have class(es): "${expectedClassList.join(' ')}"`,
103+
? `Expected the element to have exactly these classes: "${expectedClassList.join(" ")}"`
104+
: `Expected the element to have class(es): "${expectedClassList.join(" ")}"`,
105105
});
106106

107107
const invertedError = new AssertionError({
108108
actual: actualClassList,
109109
expected: expectedClassList,
110110
message: exact
111-
? `Expected the element to NOT have exactly these classes: "${expectedClassList.join(' ')}"`
112-
: `Expected the element to NOT have class(es): "${expectedClassList.join(' ')}"`,
111+
? `Expected the element to NOT have exactly these classes: "${expectedClassList.join(" ")}"`
112+
: `Expected the element to NOT have class(es): "${expectedClassList.join(" ")}"`,
113113
});
114114

115115
const assertWhen = exact
116-
? actualClassList.length === expectedClassList.length && expectedClassList.every(cls => actualClassList.includes(cls))
116+
? actualClassList.length === expectedClassList.length
117+
&& expectedClassList.every(cls => actualClassList.includes(cls))
117118
: expectedClassList.every(cls => actualClassList.includes(cls));
118119

119120
return this.execute({

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { render } from "@testing-library/react";
33

44
import { ElementAssertion } from "../../../src/lib/ElementAssertion";
55

6+
import { HaveClassTestComponent } from "./fixtures/haveClassTestComponent";
67
import { NestedElementsTestComponent } from "./fixtures/nestedElementsTestComponent";
78
import { SimpleTestComponent } from "./fixtures/simpleTestComponent";
89
import { WithAttributesTestComponent } from "./fixtures/withAttributesTestComponent";
9-
import { HaveClassTestComponent } from "./fixtures/haveClassTestComponent";
1010

1111
describe("[Unit] ElementAssertion.test.ts", () => {
1212
describe(".toBeInTheDocument", () => {
@@ -193,7 +193,7 @@ describe("[Unit] ElementAssertion.test.ts", () => {
193193
const test = new ElementAssertion(divTest);
194194
expect(() => test.toHaveClass("bar"))
195195
.toThrowError(AssertionError)
196-
.toHaveMessage(`Expected the element to have class(es): "bar"`);
196+
.toHaveMessage("Expected the element to have class(es): \"bar\"");
197197
});
198198
});
199199

@@ -207,15 +207,15 @@ describe("[Unit] ElementAssertion.test.ts", () => {
207207
});
208208
});
209209

210-
context("when the element does not have the exact matching expected class ", async () => {
210+
context("when the element does not have the exact matching expected class ", () => {
211211
it("throws an assertion error", async () => {
212212
const { findByTestId } = render(<HaveClassTestComponent />);
213213
const divTest = await findByTestId("classTest");
214214
divTest.className = "foo bar extra";
215215
const test = new ElementAssertion(divTest);
216216
expect(() => test.toHaveClass(["foo", "bar"], { exact: true }))
217217
.toThrowError(AssertionError)
218-
.toHaveMessage(`Expected the element to have exactly these classes: "foo bar"`);
218+
.toHaveMessage("Expected the element to have exactly these classes: \"foo bar\"");
219219
});
220220
});
221221
});

0 commit comments

Comments
 (0)