Skip to content

Commit

Permalink
test: Denomination buttons should update global context
Browse files Browse the repository at this point in the history
  • Loading branch information
kiocosta committed Jan 29, 2025
1 parent 774f130 commit 8e5ab05
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/components/Denomination.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { fireEvent, render, screen } from "@solidjs/testing-library";

import Denomination from "../../src/components/settings/Denomination";
import { TestComponent, contextWrapper, globalSignals } from "../helper";

describe("Denomination", () => {
test("should change denomination on button click", async () => {
render(
() => (
<>
<TestComponent />
<Denomination />
</>
),
{
wrapper: contextWrapper,
},
);

const btcDenomination = (await screen.findByTestId(
"btc-denomination-button",
)) as HTMLDivElement;
const satsDenomination = (await screen.findByTestId(
"sats-denomination-button",
)) as HTMLDivElement;

expect(btcDenomination.classList.contains("active")).toBeFalsy();
expect(satsDenomination.classList.contains("active")).toBeTruthy();
expect(globalSignals.denomination()).toEqual("sat");

fireEvent.click(btcDenomination);

expect(btcDenomination.classList.contains("active")).toBeTruthy();
expect(satsDenomination.classList.contains("active")).toBeFalsy();
expect(globalSignals.denomination()).toEqual("btc");
});
});

0 comments on commit 8e5ab05

Please sign in to comment.