Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brightiron committed Nov 7, 2023
1 parent 4a8e42f commit 9b24a73
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 123 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { cleanup } from "@testing-library/react";
import { BigNumber } from "ethers";
import { DecimalBigNumber } from "src/helpers/DecimalBigNumber/DecimalBigNumber";
import * as Balance from "src/hooks/useBalance";
import * as ContractAllowance from "src/hooks/useContractAllowance";
import * as Index from "src/hooks/useCurrentIndex";
import * as Prices from "src/hooks/usePrices";
Expand All @@ -22,16 +23,6 @@ describe("<StakeArea/> Disconnected", () => {
});
});

describe("<StakeArea/> Connected", () => {
beforeEach(async () => {
connectWallet();
render(<StakeArea />);
});
it("should render the stake input Area when connected", async () => {
expect(await screen.findByText("Unstaked Balance"));
});
});

describe("<StakeInputArea/> Connected no Approval", () => {
beforeEach(() => {
connectWallet();
Expand All @@ -44,6 +35,8 @@ describe("<StakeInputArea/> Connected no Approval", () => {
vi.spyOn(Prices, "useGohmPrice").mockReturnValue({ data: "120.56786330999999" });
//@ts-expect-error
vi.spyOn(Prices, "useOhmPrice").mockReturnValue({ data: "12.056786331" });
vi.spyOn(Balance, "useBalance").mockReturnValue({ 1: { data: new DecimalBigNumber("10", 9) } });

render(
<>
<StakeInputArea />
Expand All @@ -64,7 +57,7 @@ describe("<StakeInputArea/> Connected no Approval", () => {
// fireEvent.click(await screen.findByTestId("acknowledge-warmup"));

// expect approval
expect(await screen.findByText("Approve Staking"));
expect(await screen.findByText("Approve Wrapping"));
});
it("should successfully complete the contract approval", async () => {
fireEvent.input(await screen.findByTestId("ohm-input"), { target: { value: "0.8" } });
Expand All @@ -74,8 +67,8 @@ describe("<StakeInputArea/> Connected no Approval", () => {

// expect modal
expect(await screen.findByTestId("stake-confirmation-modal"));
expect(screen.getByText("Approve Staking"));
fireEvent.click(screen.getByText("Approve Staking"));
expect(screen.getByText("Approve Wrapping"));
fireEvent.click(screen.getByText("Approve Wrapping"));

vi.spyOn(ContractAllowance, "useContractAllowance").mockReturnValue({
data: BigNumber.from("100000000000000000000"),
Expand Down Expand Up @@ -117,12 +110,4 @@ describe("<StakeArea/> Connected with Approval", () => {
fireEvent.input(await screen.findByTestId("ohm-input"), { target: { value: "2" } });
expect(await screen.findByTestId("staked-input"), { target: { value: "22.5447803865539" } });
});

it("gOHM conversion should appear correctly when Staking ETH to gOHM", async () => {
fireEvent.click(screen.getAllByText("OHM")[0]);
expect(screen.getByText("Select a token"));
fireEvent.click(await screen.findByText("ETH"));
fireEvent.input(await screen.findByTestId("ohm-input"), { target: { value: "0.8" } });
expect(await screen.findByTestId("staked-input"), { target: { value: "22.5447803865539" } });
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe("Wrap to gOHM", () => {
fireEvent.click(await screen.findByText("Wrap to gOHM"));
// expect modal
expect(await screen.findByTestId("stake-confirmation-modal"));
expect(await screen.findByText("Approve Staking"));
expect(await screen.findByText("Approve Wrapping"));
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export const StakeInputArea: React.FC<{ isZoomed: boolean }> = props => {
{tokenModalOpen && (
<TokenModal
open={tokenModalOpen}
handleSelect={name => setStakedAssetType(name)}
handleSelect={name => (isStake ? setSwapAssetType(name) : setStakedAssetType(name))}
handleClose={() => setTokenModalOpen(false)}
ohmBalance={ohmBalance && ohmBalance.toString({ decimals: 2 })}
sOhmBalance={sOhmBalance && sOhmBalance.toString({ decimals: 2 })}
Expand Down

This file was deleted.

0 comments on commit 9b24a73

Please sign in to comment.