|
| 1 | +import { mainnet, sepolia } from "@starknet-react/chains"; |
| 2 | +import { |
| 3 | + ConnectorNotConnectedError, |
| 4 | + UserNotConnectedError, |
| 5 | +} from "@starknet-react/core"; |
| 6 | +import { BraavosMobileConnector, getBraavosMobile } from "@utils/braavosMobile"; |
| 7 | + |
| 8 | +describe("BraavosMobileConnector class", () => { |
| 9 | + let connector; |
| 10 | + |
| 11 | + beforeEach(() => { |
| 12 | + connector = new BraavosMobileConnector(); |
| 13 | + }); |
| 14 | + |
| 15 | + describe("id getter", () => { |
| 16 | + it("should return 'braavosMobile'", () => { |
| 17 | + expect(connector.id).toBe("braavosMobile"); |
| 18 | + }); |
| 19 | + }); |
| 20 | + |
| 21 | + describe("icon getter", () => { |
| 22 | + it("should return the same icon for light and dark modes", () => { |
| 23 | + expect(connector.icon.light).toBeDefined(); |
| 24 | + expect(connector.icon.dark).toBeDefined(); |
| 25 | + expect(connector.icon.light).toBe(connector.icon.dark); |
| 26 | + }); |
| 27 | + }); |
| 28 | + |
| 29 | + describe("name getter", () => { |
| 30 | + it("should return 'Braavos (mobile)'", () => { |
| 31 | + expect(connector.name).toBe("Braavos (mobile)"); |
| 32 | + }); |
| 33 | + }); |
| 34 | + |
| 35 | + describe("available method", () => { |
| 36 | + it("should return true", () => { |
| 37 | + expect(connector.available()).toBe(true); |
| 38 | + }); |
| 39 | + }); |
| 40 | + |
| 41 | + describe("wallet getter", () => { |
| 42 | + it("should throw a ConnectorNotConnectedError", () => { |
| 43 | + expect(() => connector.wallet).toThrow(ConnectorNotConnectedError); |
| 44 | + }); |
| 45 | + }); |
| 46 | + |
| 47 | + describe("disconnect method", () => { |
| 48 | + it("should throw a UserNotConnectedError", () => { |
| 49 | + expect(() => connector.disconnect()).toThrow(UserNotConnectedError); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + describe("account method", () => { |
| 54 | + it("should throw a ConnectorNotConnectedError", () => { |
| 55 | + expect(() => connector.account()).toThrow(ConnectorNotConnectedError); |
| 56 | + }); |
| 57 | + }); |
| 58 | + |
| 59 | + describe("chainId method", () => { |
| 60 | + it("should return sepolia.id when NEXT_PUBLIC_IS_TESTNET is 'true'", async () => { |
| 61 | + process.env.NEXT_PUBLIC_IS_TESTNET = "true"; |
| 62 | + const result = await connector.chainId(); |
| 63 | + expect(result).toBe(sepolia.id); |
| 64 | + }); |
| 65 | + |
| 66 | + it("should return mainnet.id when NEXT_PUBLIC_IS_TESTNET is not 'true'", async () => { |
| 67 | + process.env.NEXT_PUBLIC_IS_TESTNET = "false"; |
| 68 | + const result = await connector.chainId(); |
| 69 | + expect(result).toBe(mainnet.id); |
| 70 | + }); |
| 71 | + }); |
| 72 | + |
| 73 | + describe("ready method", () => { |
| 74 | + it("should return true as a Promise", async () => { |
| 75 | + const result = await connector.ready(); |
| 76 | + expect(result).toBe(true); |
| 77 | + }); |
| 78 | + }); |
| 79 | +}); |
| 80 | + |
| 81 | +describe("getBraavosMobile function", () => { |
| 82 | + it("should return an instance of BraavosMobileConnector", () => { |
| 83 | + const instance = getBraavosMobile(); |
| 84 | + expect(instance).toBeInstanceOf(BraavosMobileConnector); |
| 85 | + }); |
| 86 | +}); |
0 commit comments