Skip to content

Commit

Permalink
fix: unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reneaaron committed Aug 6, 2023
1 parent f536383 commit 9f2f102
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/app/screens/Home/DefaultView/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { AccountsProvider } from "../../../context/AccountsContext";
import DefaultView from "./index";
import { render, screen } from "@testing-library/react";
import { I18nextProvider } from "react-i18next";
import { MemoryRouter } from "react-router-dom";
import { settingsFixture as mockSettings } from "~/../tests/fixtures/settings";
import i18n from "~/../tests/unit/helpers/i18n";
import { BatteryFixture } from "~/fixtures/battery";

import { AccountsProvider } from "../../../context/AccountsContext";
import DefaultView from "./index";

jest.mock("~/common/lib/api", () => ({
getPayments: () => {
return {
Expand Down Expand Up @@ -66,14 +65,15 @@ describe("DefaultView", () => {
expect(await screen.findByText("Send")).toBeInTheDocument();
expect(await screen.findByText("Receive")).toBeInTheDocument();
});
test("render DefaultView with battery", async () => {
test("render DefaultView with publisher widget if enabled", async () => {
const battery = BatteryFixture[0];
render(
<AccountsProvider>
<I18nextProvider i18n={i18n}>
<MemoryRouter>
<DefaultView
currentUrl={new URL("https://github.com/")}
renderPublisherWidget={true}
lnDataFromCurrentTab={[battery]}
/>
</MemoryRouter>
Expand All @@ -87,4 +87,29 @@ describe("DefaultView", () => {
expect(await screen.findByText(battery.name)).toBeInTheDocument();
expect(await screen.findByText(battery.description)).toBeInTheDocument();
});

test("render DefaultView without PublisherWidget if disabled", async () => {
const battery = BatteryFixture[0];
render(
<AccountsProvider>
<I18nextProvider i18n={i18n}>
<MemoryRouter>
<DefaultView
currentUrl={new URL("https://github.com/")}
renderPublisherWidget={false}
lnDataFromCurrentTab={[battery]}
/>
</MemoryRouter>
</I18nextProvider>
</AccountsProvider>
);

expect(
await screen.queryByText("⚡️ Send Satoshis ⚡️")
).not.toBeInTheDocument();
expect(await screen.queryByText(battery.name)).not.toBeInTheDocument();
expect(
await screen.queryByText(battery.description)
).not.toBeInTheDocument();
});
});

0 comments on commit 9f2f102

Please sign in to comment.