Skip to content

Commit

Permalink
test: update tests that check when the ev claim is updated (#723)
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus authored Oct 16, 2023
1 parent e7cd05a commit ad12832
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 6 additions & 12 deletions test/accountlinking/emailverificationapis.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
});

describe("isEmailVerifiedGET tests", function () {
it("calling isEmailVerifiedGET gives false for currently logged in user if email is not verified, and does not update session", async function () {
it("calling isEmailVerifiedGET gives false for currently logged in user if email is not verified, and updates session", async function () {
const connectionURI = await startSTWithMultitenancyAndAccountLinking();
supertokens.init({
supertokens: {
Expand Down Expand Up @@ -555,12 +555,10 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
assert(response.body.isVerified === false);

let tokens = extractInfoFromResponse(response);
assert(tokens.accessToken === undefined);
assert(tokens.accessTokenFromAny === undefined);
assert(tokens.accessTokenFromHeader === undefined);
assert.notStrictEqual(tokens.accessTokenFromAny, undefined);
});

it("calling isEmailVerifiedGET gives true for currently logged in user if email is verified, and does not update session", async function () {
it("calling isEmailVerifiedGET gives true for currently logged in user if email is verified, and updates session", async function () {
const connectionURI = await startSTWithMultitenancyAndAccountLinking();
supertokens.init({
supertokens: {
Expand Down Expand Up @@ -643,9 +641,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
assert(response.body.isVerified === true);

let tokens = extractInfoFromResponse(response);
assert(tokens.accessToken === undefined);
assert(tokens.accessTokenFromAny === undefined);
assert(tokens.accessTokenFromHeader === undefined);
assert.notStrictEqual(tokens.accessTokenFromAny, undefined);
});

it("calling isEmailVerifiedGET gives false for currently logged in user if email is not verified, and updates session if needed", async function () {
Expand Down Expand Up @@ -928,7 +924,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
assert(userInCallback.recipeUserId.getAsString() === epUser.loginMethods[0].recipeUserId.getAsString());
});

it("calling generateEmailVerifyTokenPOST gives already verified for currently logged in user if email is verified, and does not update session", async function () {
it("calling generateEmailVerifyTokenPOST gives already verified for currently logged in user if email is verified, and updates session", async function () {
let userInCallback = undefined;
const connectionURI = await startSTWithMultitenancyAndAccountLinking();
supertokens.init({
Expand Down Expand Up @@ -1021,9 +1017,7 @@ describe(`emailverificationapiTests: ${printPath("[test/accountlinking/emailveri
assert(response.body.status === "EMAIL_ALREADY_VERIFIED_ERROR");

let tokens = extractInfoFromResponse(response);
assert(tokens.accessToken === undefined);
assert(tokens.accessTokenFromAny === undefined);
assert(tokens.accessTokenFromHeader === undefined);
assert.notStrictEqual(tokens.accessTokenFromAny, undefined);

assert(userInCallback === undefined);
});
Expand Down
2 changes: 1 addition & 1 deletion test/emailpassword/emailverify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ describe(`emailverify: ${printPath("[test/emailpassword/emailverify.test.js]")}`
let infoFromResponse2 = extractInfoFromResponse(response);
assert.strictEqual(response.statusCode, 200);
assert.deepStrictEqual(response.body.status, "EMAIL_ALREADY_VERIFIED_ERROR");
assert.strictEqual(infoFromResponse2.frontToken, undefined);
assert.notStrictEqual(infoFromResponse2.frontToken, undefined);

// now we mark the email as unverified and try again
await EmailVerification.unverifyEmail(userId, emailId);
Expand Down

0 comments on commit ad12832

Please sign in to comment.