Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Campaign List Test #2476

Open
wants to merge 4 commits into
base: stage-main-14.2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions __test__/containers/CampaignList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* @jest-environment jsdom
*/
import React from "react";
import { mount } from "enzyme";
import { act } from "react-dom/test-utils";
import {
render,
Expand Down Expand Up @@ -31,9 +30,9 @@ describe("CampaignList", () => {
};

const mutations = {
createCampaign: () => {},
archiveCampaigns: () => {},
unarchiveCampaign: () => {}
createCampaign: () => { },
archiveCampaigns: () => { },
unarchiveCampaign: () => { }
};

describe("Campaign list for campaign with null creator", () => {
Expand Down Expand Up @@ -71,15 +70,27 @@ describe("CampaignList", () => {
// when
test("Renders for campaign with null creator, doesn't include created by", () => {
StyleSheetTestUtils.suppressStyleInjection();
const wrapper = mount(
<AdminCampaignList data={data} mutations={mutations} params={params} />
);
const text = wrapper.text();
expect(text.includes("Created by")).toBeFalsy();
expect(text.includes("Yes on A")).toBeTruthy();
expect(text).toMatch(/Archive/);
expect(text).toMatch(/1202/);
expect(text).toMatch(/1101/);
act(() => {
render(
<AdminCampaignList data={data} mutations={mutations} params={params} />
);
});

const cells = screen.getAllByRole('cell');

expect(cells.length).toBe(7);
// campaign ID cell
expect(cells[1].textContent).toContain("1");
// campaign info cell
expect(cells[2].textContent).toContain("Yes on A");
// campaign info cell - lack of "created by" due to creator = null
expect(cells[2].textContent).not.toContain("Created by");
// unassigned contacts
expect(cells[3].textContent).toContain("1101");
// unmessaged contacts
expect(cells[4].textContent).toContain("1202");
// archive
expect(cells[5].textContent).toBe("Archive");
});
});

Expand Down Expand Up @@ -114,14 +125,16 @@ describe("CampaignList", () => {
// when
test("Renders for campaign with creator, includes created by", () => {
StyleSheetTestUtils.suppressStyleInjection();
const wrapper = mount(
<AdminCampaignList data={data} mutations={mutations} params={params} />
);
expect(
wrapper.containsMatchingElement(
<span> &mdash; Created by Lorem Ipsum</span>
)
).toBeTruthy();
act(() => {
render(
<AdminCampaignList data={data} mutations={mutations} params={params} />
);
});
const cells = screen.getAllByRole('cell');

expect(cells.length).toBe(7);
// campaign info cell
expect(cells[2].textContent).toBe("Campaign — Created by Lorem Ipsum");
});
});

Expand Down Expand Up @@ -152,7 +165,7 @@ describe("CampaignList", () => {
}
}
},
refetch: () => {}
refetch: () => { }
};

test("Timezone column is displayed when timezone is current sort", async () => {
Expand Down
Loading