Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchand-Nicolas committed Dec 27, 2024
1 parent 787399c commit efe262d
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
86 changes: 86 additions & 0 deletions tests/utils/braavosMobile.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import { mainnet, sepolia } from "@starknet-react/chains";
import {
ConnectorNotConnectedError,
UserNotConnectedError,
} from "@starknet-react/core";
import { BraavosMobileConnector, getBraavosMobile } from "@utils/braavosMobile";

describe("BraavosMobileConnector class", () => {
let connector;

beforeEach(() => {
connector = new BraavosMobileConnector();
});

describe("id getter", () => {
it("should return 'braavosMobile'", () => {
expect(connector.id).toBe("braavosMobile");
});
});

describe("icon getter", () => {
it("should return the same icon for light and dark modes", () => {
expect(connector.icon.light).toBeDefined();
expect(connector.icon.dark).toBeDefined();
expect(connector.icon.light).toBe(connector.icon.dark);
});
});

describe("name getter", () => {
it("should return 'Braavos (mobile)'", () => {
expect(connector.name).toBe("Braavos (mobile)");
});
});

describe("available method", () => {
it("should return true", () => {
expect(connector.available()).toBe(true);
});
});

describe("wallet getter", () => {
it("should throw a ConnectorNotConnectedError", () => {
expect(() => connector.wallet).toThrow(ConnectorNotConnectedError);
});
});

describe("disconnect method", () => {
it("should throw a UserNotConnectedError", () => {
expect(() => connector.disconnect()).toThrow(UserNotConnectedError);
});
});

describe("account method", () => {
it("should throw a ConnectorNotConnectedError", () => {
expect(() => connector.account()).toThrow(ConnectorNotConnectedError);
});
});

describe("chainId method", () => {
it("should return sepolia.id when NEXT_PUBLIC_IS_TESTNET is 'true'", async () => {
process.env.NEXT_PUBLIC_IS_TESTNET = "true";
const result = await connector.chainId();
expect(result).toBe(sepolia.id);
});

it("should return mainnet.id when NEXT_PUBLIC_IS_TESTNET is not 'true'", async () => {
process.env.NEXT_PUBLIC_IS_TESTNET = "false";
const result = await connector.chainId();
expect(result).toBe(mainnet.id);
});
});

describe("ready method", () => {
it("should return true as a Promise", async () => {
const result = await connector.ready();
expect(result).toBe(true);
});
});
});

describe("getBraavosMobile function", () => {
it("should return an instance of BraavosMobileConnector", () => {
const instance = getBraavosMobile();
expect(instance).toBeInstanceOf(BraavosMobileConnector);
});
});
2 changes: 1 addition & 1 deletion utils/braavosMobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const braavosMobileIcon =
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFwAAABcCAYAAADj79JYAAAAIGNIUk0AAHomAACAhAAA+gAAAIDoAAB1MAAA6mAAADqYAAAXcJy6UTwAAAAGYktHRAD/AP8A/6C9p5MAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAAHdElNRQfoDBoIMDQ8dvpLAAADI3pUWHRSYXcgcHJvZmlsZSB0eXBlIHhtcAAASInFVkuWnDAM3OsUOQJItgTHoTHs8l6WOX6q5P7Q3cxkkizSvAHGlkqlr5Gf33/IN/xGLZPYantMMfjo5hevUXRw9erhs2/WVLf9crnsqlifvXClhtXSbCgthmKQnXyWMsUSUKwWS9lqcTwBaAYlVdtt08HWmGyJyaHojcZ81IH/++pbGPeEFsCm+E4etvSNu3gyecBg7UKNctfQoU6l1UGU5PbIJZt1s1Eb+Ay4AGHBNR/N+WfgifsEAyv2lDJWdMfTJB+uzUZci1VsLVgB7MulVycVXNyWqqUUfzgo6WHfpJNTFFyDLXBqj/zpFhACL/IOGB7BC1dSUNwV9yYdRFtYIEuMS0xwDpHi/jMLUEDCkA71OeM1I06Q4L5QAMFW2EN4yaqH95gRhvmdbxrbbokSBHlDBe3e4ArCGAPJI+jDLWMPSKjYSQAGUADQ+vCegrhXKFYWAF2F1Q48vgOjqiboglGY5OtviT/xPqh3bZqScyd6XEpDI3zRhJzFBoDtBNyilBreU/IKLh868ALOPg0kHTJ71SwD5lkhXwkvPaSsmW6fNgorpQKIcdBKI7uvbz32FCvJYLFnKjMD+4OiCXOo9AJNMZ0/MFRL6c/s/nv7YcZApu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07FO7VrMuWCLR128DmHFdQPHG6Vcg7ZbbRygZCPv3AmTPkKgDUxIlRVPm1k7XZGma9QseoJ1BvnaxICkk0IEqqSYK+sWC2Uqbc9TyJbW7xwQcLGwf9NZJkJC1UJkQPOoVuDRDAFz0ze8OEdQG/7ep/Srj3P+xRtYD4LIdWvqA/eAgU0/1i7l69xALnFZZTxkzl9GfKBIKI2TJ4C52bGJJvILbhUfyTQ/mMnrbiezjxgjpT6SqbwdwmVVEZo2HdjFfVdzgcxA1gkrJr/D9megfURW/pyAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDI0LTEyLTI2VDA4OjQ4OjM0KzAwOjAwRY7yjQAAACV0RVh0ZGF0ZTptb2RpZnkAMjAyNC0xMi0yNlQwODo0ODozNCswMDowMDTTSjEAAAAodEVYdGRhdGU6dGltZXN0YW1wADIwMjQtMTItMjZUMDg6NDg6NTIrMDA6MDDGeVdTAAAAAElFTkSuQmCC";

// @ts-ignore
class BraavosMobileConnector extends Connector {
export class BraavosMobileConnector extends Connector {
get id(): string {
return "braavosMobile";
}
Expand Down

0 comments on commit efe262d

Please sign in to comment.