Skip to content

Commit

Permalink
Rewrite test
Browse files Browse the repository at this point in the history
  • Loading branch information
nbarnabee committed Mar 21, 2023
1 parent 79f64ea commit 69e4923
Showing 1 changed file with 11 additions and 69 deletions.
80 changes: 11 additions & 69 deletions src/components/__tests__/Home.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,10 @@ describe("Home", () => {
const profileBaseUrl = "https://meta.wikimedia.org/wiki/User:";
it("renders properly", () => {
const HomeProps = {
tasks: [
{
field: {
description: "a thing for doing the thing",
input_options: null,
name: "wikidata_qid",
},
id: 1,
timestamp: null,
tool: {
description: "Shows you little things you can do on Wikidata.",
name: "mm_wikidata_todo",
title: "Wikidata Todo",
url: "http://tools.wmflabs.org/wikidata-todo",
},
user: null,
},
],
toolName: "mm_wikidata_todo",
toolDescription: "Shows you little things you can do on Wikidata.",
missingField: "wikidata_qid",
toolURL: "http://tools.wmflabs.org/wikidata-todo",
};
const wrapper = mount(Home, {
props: HomeProps,
Expand All @@ -34,7 +20,7 @@ describe("Home", () => {
},
});
const rows = wrapper.find("tbody").findAll("tr");
expect(rows[0].findAll("td")[1].text()).toBe("Wikidata Todo");
expect(rows[0].findAll("td")[1].text()).toBe("mm_wikidata_todo");
expect(rows[1].findAll("td")[1].text()).toBe(
"Shows you little things you can do on Wikidata."
);
Expand All @@ -46,42 +32,12 @@ describe("Home", () => {

it("shows next task when skip next is clicked", async () => {
const HomeProps = {
tasks: [
{
field: {
description: "a thing for doing the thing",
input_options: null,
name: "wikidata_qid",
},
id: 1,
timestamp: null,
tool: {
description:
"Python library and collection of scripts that automate work on MediaWiki sites",
name: "Pywikibot",
title: "Pywikibot",
url: "https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot",
},
user: null,
},
{
field: {
description: "a thing for doing the thing",
input_options: null,
name: "openhub_id",
},
id: 1,
timestamp: null,
tool: {
description:
"This project is aimed at getting very basic author statistics for a specified page.",
name: "toolforge-authors",
title: "Authors of a page",
url: "https://toolsadmin.wikimedia.org/tools/id/authors",
},
user: null,
},
],
toolName: "Pywikibot",
toolDescription:
"Python library and collection of scripts that automate work on MediaWiki sites",
missingField: "wikidata_qid",
toolURL:
"https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot",
};
const wrapper = mount(Home, {
props: HomeProps,
Expand All @@ -98,19 +54,5 @@ describe("Home", () => {
"https://www.mediawiki.org/wiki/Special:MyLanguage/Manual:Pywikibot"
);
expect(rows[3].findAll("td")[1].text()).toBe("wikidata_qid");

// click on Skip to Next button
await wrapper.findAll("button")[1].trigger("click");

// Expect the table to be updated with the next task details
const updatedRows = wrapper.find("tbody").findAll("tr");
expect(rows[0].findAll("td")[1].text()).toBe("Authors of a page");
expect(rows[1].findAll("td")[1].text()).toBe(
"This project is aimed at getting very basic author statistics for a specified page."
);
expect(rows[2].findAll("td")[1].text()).toBe(
"https://toolsadmin.wikimedia.org/tools/id/authors"
);
expect(rows[3].findAll("td")[1].text()).toBe("openhub_id");
});
});

0 comments on commit 69e4923

Please sign in to comment.