Skip to content

Commit

Permalink
tests: useRedirectionRule when the session was blocked
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmuniz1994 committed Oct 27, 2023
1 parent 7bb6a70 commit 593f691
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions src/hooks/useRedirectionRule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,32 @@ import { getRedirectionRule } from "./useRedirectionRule";

describe("getRedirectionRule: / (auth)", () => {
it("when authenticated, go to creation", () => {
const result = getRedirectionRule({ path: "/", hasAuth: true }, {});
const result = getRedirectionRule(
{ path: "/", hasAuth: true, isSessionBlocked: false },
{}
);
expect(result).toBe("/create");
});

it("when not authenticated, stay here for auth", () => {
const result = getRedirectionRule({ path: "/", hasAuth: false }, {});
const result = getRedirectionRule(
{ path: "/", hasAuth: false, isSessionBlocked: false },
{}
);
expect(result).toBe("");
});

it("when autenticated and provided joining uid, then go to join page proceed to device testing", () => {
const result = getRedirectionRule(
{ path: "/", hasAuth: true },
{ path: "/", hasAuth: true, isSessionBlocked: false },
{ joining: "123-321" }
);
expect(result).toBe("/join?callUid=123-321");
});

it("when autenticated and provided creating display name, then go to create page proceed to device testing", () => {
const result = getRedirectionRule(
{ path: "/", hasAuth: true },
{ path: "/", hasAuth: true, isSessionBlocked: false },
{ creating: "Daily" }
);
expect(result).toBe("/create?callDisplayName=Daily"); // TODO: names with special characters?
Expand Down Expand Up @@ -57,6 +63,19 @@ describe("getRedirectionRule: /create", () => {
);
expect(result).toBe("/p2p-call/123-321");
});

it("when session is blocked, got to blocked session page", () => {
const result = getRedirectionRule(
{
path: "/create",
hasAuth: true,
ongoingCall: "123-321",
isSessionBlocked: true,
},
{}
);
expect(result).toBe("/blocked-session");
});
});

describe("getRedirectionRule: /join", () => {
Expand Down Expand Up @@ -104,6 +123,19 @@ describe("getRedirectionRule: /join", () => {
);
expect(result).toBe("/pending");
});

it("when session is blocked, got to blocked session page", () => {
const result = getRedirectionRule(
{
path: "/join",
hasAuth: true,
pendingCall: "123-call-321",
isSessionBlocked: true,
},
{}
);
expect(result).toBe("/blocked-session");
});
});

describe("getRedirectionRule: /join", () => {
Expand Down Expand Up @@ -148,6 +180,14 @@ describe("getRedirectionRule: /join", () => {
);
expect(result).toBe("/");
});

it("when session is blocked, got to blocked session page", () => {
const result = getRedirectionRule(
{ path: "/pending", hasAuth: true, isSessionBlocked: true },
{}
);
expect(result).toBe("/blocked-session");
});
});

describe("getRedirectionRule: /p2p-call", () => {
Expand Down Expand Up @@ -181,4 +221,12 @@ describe("getRedirectionRule: /p2p-call", () => {
);
expect(result).toBe("/");
});

it("when session is blocked, got to blocked session page", () => {
const result = getRedirectionRule(
{ path: "/p2p-call/123-321", hasAuth: false, isSessionBlocked: true },
{}
);
expect(result).toBe("/blocked-session");
});
});

0 comments on commit 593f691

Please sign in to comment.