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

test(utils): add unit test for account store (mobx) #770

Merged
merged 4 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Improvements

- [#770](https://github.com/alleslabs/celatone-frontend/pull/770) Add unit test for account store (mobx)
- [#769](https://github.com/alleslabs/celatone-frontend/pull/769) Add unit test for format.test.ts on shortenName function
- [#768](https://github.com/alleslabs/celatone-frontend/pull/768) Add unit test for truncate.test.ts
- [#767](https://github.com/alleslabs/celatone-frontend/pull/767) Add unit test for fee.test.ts
Expand Down
49 changes: 49 additions & 0 deletions src/lib/stores/account.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { zBechAddr } from "lib/types";

import { AccountStore } from "./account";

describe("accountStore", () => {
let accountStore: AccountStore;
const address = zBechAddr.parse("address");

beforeEach(() => {
accountStore = new AccountStore();
});

test("user key management", () => {
expect(accountStore.isAccountUserKeyExist()).toBeFalsy();

accountStore.setAccountUserKey("user-key");

expect(accountStore.isAccountUserKeyExist()).toBeTruthy();
});

test("account info", () => {
expect(accountStore.getAccountLocalInfo(address)).toBeUndefined();

accountStore.updateAccountLocalInfo(address, "name", "description");

expect(accountStore.getAccountLocalInfo(address)).toEqual({
address: "address",
name: "name",
description: "description",
});
});

test("saved account", () => {
expect(accountStore.savedAccounts).toEqual({});
expect(accountStore.isAccountSaved(address)).toBeFalsy();

accountStore.updateAccountLocalInfo(address, "name", "description");

expect(accountStore.isAccountSaved(address)).toBeTruthy();

expect(accountStore.getSavedAccounts()).toEqual([
{
address: "address",
name: "name",
description: "description",
},
]);
});
});
Loading