Skip to content

Commit

Permalink
Rewrite the test function
Browse files Browse the repository at this point in the history
The test was written supposing a certain structure to Home.vue.  Now
that structure has been completely reworked, the test (unsurprisingly)
cannot pass.
  • Loading branch information
nbarnabee committed Mar 10, 2023
1 parent 2c0b9d4 commit 5062dd3
Showing 1 changed file with 10 additions and 66 deletions.
76 changes: 10 additions & 66 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 @@ -46,40 +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: "Wikidata Todo",
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 @@ -96,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("toolforge-authors");
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 5062dd3

Please sign in to comment.