Enable and apply ESLint Jest rules (#3270)

Jest was in the plugin array of the ESLint configuration, but no rules
were enabled. So ESLint hasn't checked any Jest rules yet.

So I activated the recommended Jest rules and added a few more. Then I
fixed the issues (mostly automatically). I have deactivated the rules
"jest/expect-expect" and "jest/no-done-callback" for the time being, as
they would have entailed major changes. I didn't want to make the PR too
big.

I'm not a Jest expert, but the changes so far look good to me. What do
you think of that @khassel? 🙂
This commit is contained in:
Kristjan ESPERANTO
2023-11-20 20:11:41 +01:00
committed by GitHub
parent 679a413788
commit 7098f1e41f
32 changed files with 113 additions and 105 deletions

View File

@@ -13,20 +13,20 @@ describe("Newsfeed module", () => {
it("should show the newsfeed title", async () => {
const elem = await helpers.waitForElement(".newsfeed .newsfeed-source");
expect(elem).not.toBe(null);
expect(elem).not.toBeNull();
expect(elem.textContent).toContain("Rodrigo Ramirez Blog");
});
it("should show the newsfeed article", async () => {
const elem = await helpers.waitForElement(".newsfeed .newsfeed-title");
expect(elem).not.toBe(null);
expect(elem).not.toBeNull();
expect(elem.textContent).toContain("QPanel");
});
it("should NOT show the newsfeed description", async () => {
await helpers.waitForElement(".newsfeed");
const elem = document.querySelector(".newsfeed .newsfeed-desc");
expect(elem).toBe(null);
expect(elem).toBeNull();
});
});
@@ -38,14 +38,14 @@ describe("Newsfeed module", () => {
it("should not show articles with prohibited words", async () => {
const elem = await helpers.waitForElement(".newsfeed .newsfeed-title");
expect(elem).not.toBe(null);
expect(elem).not.toBeNull();
expect(elem.textContent).toContain("Problema VirtualBox");
});
it("should show the newsfeed description", async () => {
const elem = await helpers.waitForElement(".newsfeed .newsfeed-desc");
expect(elem).not.toBe(null);
expect(elem.textContent.length).not.toBe(0);
expect(elem).not.toBeNull();
expect(elem.textContent).not.toHaveLength(0);
});
});
@@ -57,7 +57,7 @@ describe("Newsfeed module", () => {
it("should show malformed url warning", async () => {
const elem = await helpers.waitForElement(".newsfeed .small", "No news at the moment.");
expect(elem).not.toBe(null);
expect(elem).not.toBeNull();
expect(elem.textContent).toContain("Error in the Newsfeed module. Malformed url.");
});
});
@@ -70,7 +70,7 @@ describe("Newsfeed module", () => {
it("should show empty items info message", async () => {
const elem = await helpers.waitForElement(".newsfeed .small");
expect(elem).not.toBe(null);
expect(elem).not.toBeNull();
expect(elem.textContent).toContain("No news at the moment.");
});
});