Skip to content

Commit

Permalink
fix: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
qperrot committed Jan 13, 2025
1 parent db24171 commit 59ab137
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions libs/coin-framework/src/account/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,36 @@ describe(isAccountEmpty.name, () => {
expect(isAccountEmpty(mockAccount)).toEqual(false);
});
});
describe("when account has subaccounts", () => {
beforeEach(() => {
mockAccount.subAccounts = [{} as TokenAccount];
});

it("should return false", () => {
expect(isAccountEmpty(mockAccount)).toEqual(false);
});
});
});
describe("given an solana account", () => {
beforeEach(() => {
mockAccount.type = "Account";
mockAccount.currency = { family: "solana" } as CryptoCurrency;
});
it("Account has balance and spendableBalance is zero ", () => {
mockAccount.balance = new BigNumber(10);
mockAccount.spendableBalance = new BigNumber(0);
expect(isAccountEmpty(mockAccount)).toEqual(true);
});
it("Account has spendableBalance and balance is zero", () => {
mockAccount.balance = new BigNumber(0);
mockAccount.spendableBalance = new BigNumber(10);
expect(isAccountEmpty(mockAccount)).toEqual(true);
});
it("Account has spendableBalance and has balance", () => {
mockAccount.balance = new BigNumber(10);
mockAccount.spendableBalance = new BigNumber(10);
expect(isAccountEmpty(mockAccount)).toEqual(false);
});
});
});

Expand Down

0 comments on commit 59ab137

Please sign in to comment.