Skip to content

Commit

Permalink
chore: added wrong appId tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ignaciosantise committed Dec 6, 2024
1 parent 7b6f47d commit 893d6de
Showing 1 changed file with 44 additions and 2 deletions.
46 changes: 44 additions & 2 deletions packages/core/test/relayer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ describe("Relayer", () => {
expect(relayer.connected).to.be.true;
});

it("[Android] send packageName undefined - should connect", async () => {
it("[Android] packageName undefined - should connect", async () => {
// Mock Android environment
vi.spyOn(utils, "isAndroid").mockReturnValue(true);
vi.spyOn(utils, "isIos").mockReturnValue(false);
Expand All @@ -399,6 +399,27 @@ describe("Relayer", () => {
expect(relayer.connected).to.be.true;
});

it("[Android] packageName not included in Cloud Settings - should fail", async () => {
// Mock Android environment
vi.spyOn(utils, "isAndroid").mockReturnValue(true);
vi.spyOn(utils, "isIos").mockReturnValue(false);
vi.spyOn(utils, "getAppId").mockReturnValue("com.example.wrong");

relayer = new Relayer({
core,
relayUrl: TEST_CORE_OPTIONS.relayUrl,
projectId: TEST_PROJECT_ID_MOBILE,
});

await relayer.init();
await relayer.transportOpen();
relayer.provider.on(RELAYER_PROVIDER_EVENTS.payload, (payload) => {
expect(payload.error.message).to.include("Unauthorized: origin not allowed");
});

await throttle(1000);
});

it("[iOS] bundleId included in Cloud Settings - should connect", async () => {
// Mock iOS environment
vi.spyOn(utils, "isAndroid").mockReturnValue(false);
Expand All @@ -419,7 +440,7 @@ describe("Relayer", () => {
expect(wsUrl).to.include(`bundleId=${TEST_MOBILE_APP_ID}`);
});

it("[iOS] send bundleId undefined - should connect", async () => {
it("[iOS] bundleId undefined - should connect", async () => {
// Mock iOS environment
vi.spyOn(utils, "isAndroid").mockReturnValue(false);
vi.spyOn(utils, "isIos").mockReturnValue(true);
Expand All @@ -440,6 +461,27 @@ describe("Relayer", () => {
expect(relayer.connected).to.be.true;
});

it("[iOS] bundleId not included in Cloud Settings - should fail", async () => {
// Mock iOS environment
vi.spyOn(utils, "isAndroid").mockReturnValue(false);
vi.spyOn(utils, "isIos").mockReturnValue(true);
vi.spyOn(utils, "getAppId").mockReturnValue("com.example.wrong");

relayer = new Relayer({
core,
relayUrl: TEST_CORE_OPTIONS.relayUrl,
projectId: TEST_PROJECT_ID_MOBILE,
});

await relayer.init();
await relayer.transportOpen();
relayer.provider.on(RELAYER_PROVIDER_EVENTS.payload, (payload) => {
expect(payload.error.message).to.include("Unauthorized: origin not allowed");
});

await throttle(1000);
});

it("[Web] packageName and bundleId not set - should connect", async () => {
// Mock non-mobile environment
vi.spyOn(utils, "isAndroid").mockReturnValue(false);
Expand Down

0 comments on commit 893d6de

Please sign in to comment.