Skip to content

Commit

Permalink
Fix unit tests (#775)
Browse files Browse the repository at this point in the history
  • Loading branch information
anku255 committed Dec 11, 2023
1 parent 4f50dbc commit 647d83a
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 14 deletions.
2 changes: 0 additions & 2 deletions test/unit/componentOverrides.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import { SendVerifyEmail } from "../../lib/ts/recipe/emailverification/component
import { VerifyEmailLinkClicked } from "../../lib/ts/recipe/emailverification/components/themes/emailVerification/verifyEmailLinkClicked";
import { Header as ThirdPartyEmailPasswordHeader } from "../../lib/ts/recipe/thirdpartyemailpassword/components/themes/signInAndUp/header";
import { Header as ThirdPartyPasswordlessHeader } from "../../lib/ts/recipe/thirdpartypasswordless/components/themes/signInUp/header";
import { CloseTabScreen } from "../../lib/ts/recipe/passwordless/components/themes/signInUp/closeTabScreen";
import { ComponentOverride } from "../../lib/ts/components/componentOverride/componentOverride";
import { LinkClickedScreen } from "../../lib/ts/recipe/passwordless/components/themes/linkClickedScreen";
import { LinkSent } from "../../lib/ts/recipe/passwordless/components/themes/signInUp/linkSent";
Expand Down Expand Up @@ -101,7 +100,6 @@ describe("Theme component overrides", () => {
PasswordlessUserInputCodeFormFooter_Override: UserInputCodeFormFooter,
PasswordlessUserInputCodeFormHeader_Override: UserInputCodeFormHeader,
PasswordlessLinkSent_Override: LinkSent,
PasswordlessCloseTabScreen_Override: CloseTabScreen,
PasswordlessLinkClickedScreen_Override: LinkClickedScreen,
ThirdPartyPasswordlessHeader_Override: ThirdPartyPasswordlessHeader,
};
Expand Down
8 changes: 5 additions & 3 deletions test/unit/recipe/emailpassword/emailPassword.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,11 @@ describe("EmailPassword", function () {
}).authReact(SuperTokens.getInstanceOrThrow().appInfo, false);

assert(
(await EmailPassword.getInstanceOrThrow().getRedirectUrl({ action: "SUCCESS", isNewRecipeUser: false })) ===
null
(await EmailPassword.getInstanceOrThrow().getRedirectUrl(
{ action: "SUCCESS", isNewRecipeUser: false, isNewPrimaryUser: false },
{}
)) === null
);
assert((await EmailPassword.getInstanceOrThrow().getRedirectUrl({ action: "RESET_PASSWORD" })) === null);
assert((await EmailPassword.getInstanceOrThrow().getRedirectUrl({ action: "RESET_PASSWORD" }, {})) === null);
});
});
7 changes: 6 additions & 1 deletion test/unit/recipe/emailpassword/signInUp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ describe("EmailPassword.SignInAndUp", () => {
expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith(
{
rid: "emailpassword",
successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined },
successRedirectContext: {
action: "SUCCESS",
isNewRecipeUser: false,
isNewPrimaryUser: false,
redirectToPath: undefined,
},
},
{},
undefined
Expand Down
2 changes: 1 addition & 1 deletion test/unit/recipe/passwordless/passwordless.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ describe("Passwordless", function () {
assert.throws(() => Passwordless.getInstanceOrThrow().config.onHandleEvent({} as any), {
message: "ON HANDLE EVENTS HOOK THROWS",
});
assert.throws(() => Passwordless.getInstanceOrThrow().config.getRedirectionURL({} as any), {
assert.throws(() => Passwordless.getInstanceOrThrow().config.getRedirectionURL({} as any, {}), {
message: "GET REDIRECTION HOOK THROWS",
});
});
Expand Down
7 changes: 6 additions & 1 deletion test/unit/recipe/passwordless/signInUp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ describe("Passwordless.SingInUp", () => {
expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith(
{
rid: "passwordless",
successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined },
successRedirectContext: {
action: "SUCCESS",
isNewRecipeUser: false,
isNewPrimaryUser: false,
redirectToPath: undefined,
},
},
{},
undefined
Expand Down
12 changes: 10 additions & 2 deletions test/unit/recipe/session/sessionAuth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,11 @@ describe("SessionAuth", () => {
]);

// then
expect(mockRedirectToAuth).toHaveBeenLastCalledWith({ redirectBack: true, history: undefined });
expect(mockRedirectToAuth).toHaveBeenLastCalledWith({
redirectBack: true,
navigate: undefined,
userContext: {},
});
});

test("not redirect on UNAUTHORISED if doRedirection=false", async () => {
Expand Down Expand Up @@ -673,7 +677,11 @@ describe("SessionAuth", () => {

// then
expect(child).not.toBeInTheDocument();
expect(mockRedirectToAuth).toHaveBeenLastCalledWith({ redirectBack: true, history: undefined });
expect(mockRedirectToAuth).toHaveBeenLastCalledWith({
redirectBack: true,
navigate: undefined,
userContext: {},
});
});

test("not redirect on session load if doRedirection=false", async () => {
Expand Down
7 changes: 6 additions & 1 deletion test/unit/recipe/thirdparty/signInUp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ describe("ThirdParty.SignInAndUp", () => {
expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith(
{
rid: "thirdparty",
successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined },
successRedirectContext: {
action: "SUCCESS",
isNewRecipeUser: false,
isNewPrimaryUser: false,
redirectToPath: undefined,
},
},
{},
undefined
Expand Down
2 changes: 1 addition & 1 deletion test/unit/recipe/thirdparty/thirdParty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ describe("ThirdParty", function () {
assert.throws(() => ThirdParty.getInstanceOrThrow().config.onHandleEvent({} as any), {
message: "ON HANDLE EVENTS HOOK THROWS",
});
assert.throws(() => ThirdParty.getInstanceOrThrow().config.getRedirectionURL({} as any), {
assert.throws(() => ThirdParty.getInstanceOrThrow().config.getRedirectionURL({} as any, {}), {
message: "GET REDIRECTION HOOK THROWS",
});
});
Expand Down
7 changes: 6 additions & 1 deletion test/unit/recipe/thirdpartyemailpassword/signInUp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ describe("ThirdPartyEmailPassword.SignInAndUp", () => {
expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith(
{
rid: "thirdpartyemailpassword",
successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined },
successRedirectContext: {
action: "SUCCESS",
isNewRecipeUser: false,
isNewPrimaryUser: false,
redirectToPath: undefined,
},
},
{},
undefined
Expand Down
7 changes: 6 additions & 1 deletion test/unit/recipe/thirdpartypasswordless/signInUp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ describe("ThirdPartyPasswordless.SignInAndUp", () => {
expect(MockSession.validateGlobalClaimsAndHandleSuccessRedirection).toHaveBeenCalledWith(
{
rid: "thirdpartypasswordless",
successRedirectContext: { action: "SUCCESS", isNewRecipeUser: false, redirectToPath: undefined },
successRedirectContext: {
action: "SUCCESS",
isNewRecipeUser: false,
isNewPrimaryUser: false,
redirectToPath: undefined,
},
},
{},
undefined
Expand Down

0 comments on commit 647d83a

Please sign in to comment.