Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Jul 13, 2023
1 parent 8f3a19d commit 96baaa7
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 deletions.
20 changes: 10 additions & 10 deletions test/thirdpartyemailpassword/emailDelivery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
app.use(middleware());
app.use(errorHandler());

await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");

let appName = undefined;
let email = undefined;
Expand Down Expand Up @@ -113,7 +113,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
app.use(middleware());
app.use(errorHandler());

await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");

let appName = undefined;
let email = undefined;
Expand Down Expand Up @@ -186,7 +186,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
app.use(middleware());
app.use(errorHandler());

await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");

await supertest(app)
.post("/auth/user/password/reset/token")
Expand Down Expand Up @@ -260,7 +260,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
assert.strictEqual(email, undefined);
assert.strictEqual(passwordResetURL, undefined);

await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");

await supertest(app)
.post("/auth/user/password/reset/token")
Expand Down Expand Up @@ -373,7 +373,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
app.use(middleware());
app.use(errorHandler());

await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");

process.env.TEST_MODE = "production";

Expand Down Expand Up @@ -477,7 +477,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
app.use(middleware());
app.use(errorHandler());

await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");

await supertest(app)
.post("/auth/user/password/reset/token")
Expand Down Expand Up @@ -528,7 +528,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
});
app.use(errorHandler());

let user = await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
let user = await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");
let res = extractInfoFromResponse(await supertest(app).post("/create").send({ id: user.user.id }).expect(200));

let appName = undefined;
Expand Down Expand Up @@ -587,7 +587,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
});
app.use(errorHandler());

let user = await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
let user = await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");
let res = extractInfoFromResponse(await supertest(app).post("/create").send({ id: user.user.id }).expect(200));

let appName = undefined;
Expand Down Expand Up @@ -665,7 +665,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
});
app.use(errorHandler());

let user = await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
let user = await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");
let res = extractInfoFromResponse(await supertest(app).post("/create").send({ id: user.user.id }).expect(200));

process.env.TEST_MODE = "production";
Expand Down Expand Up @@ -770,7 +770,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartyemailpassword/emailDeliver
});
app.use(errorHandler());

let user = await ThirdPartyEmailPassword.emailPasswordSignUp("test@example.com", "1234abcd");
let user = await ThirdPartyEmailPassword.emailPasswordSignUp("public", "test@example.com", "1234abcd");
let res = extractInfoFromResponse(await supertest(app).post("/create").send({ id: user.user.id }).expect(200));

await supertest(app)
Expand Down
4 changes: 2 additions & 2 deletions test/thirdpartyemailpassword/getUsersByEmailFeature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe(`getUsersByEmail: ${printPath("[test/thirdpartyemailpassword/getUsersBy
// given there are no users

// when
const thirdPartyUsers = await getUsersByEmail("john.doe@example.com");
const thirdPartyUsers = await getUsersByEmail("public", "john.doe@example.com");

// then
assert.strictEqual(thirdPartyUsers.length, 0);
Expand Down Expand Up @@ -91,7 +91,7 @@ describe(`getUsersByEmail: ${printPath("[test/thirdpartyemailpassword/getUsersBy
await thirdPartyManuallyCreateOrUpdateUser("mock", "thirdPartyJohnDoe", "john.doe@example.com");
await thirdPartyManuallyCreateOrUpdateUser("mock2", "thirdPartyDaveDoe", "john.doe@example.com");

const thirdPartyUsers = await getUsersByEmail("john.doe@example.com");
const thirdPartyUsers = await getUsersByEmail("public", "john.doe@example.com");

assert.strictEqual(thirdPartyUsers.length, 3);

Expand Down
14 changes: 10 additions & 4 deletions test/thirdpartyemailpassword/signupFeature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,10 @@ describe(`signupTest: ${printPath("[test/thirdpartyemailpassword/signupFeature.t

let thirdPartyRecipe = ThirdPartyEmailPasswordRecipe.getInstanceOrThrowError();

assert.strictEqual(await ThirdPartyEmailPassword.getUserByThirdPartyInfo("custom", "user"), undefined);
assert.strictEqual(
await ThirdPartyEmailPassword.getUserByThirdPartyInfo("public", "custom", "user"),
undefined
);

const app = express();

Expand Down Expand Up @@ -710,7 +713,7 @@ describe(`signupTest: ${printPath("[test/thirdpartyemailpassword/signupFeature.t
assert.strictEqual(response.statusCode, 200);

let signUpUserInfo = response.body.user;
let userInfo = await ThirdPartyEmailPassword.getUserByThirdPartyInfo("custom", "user");
let userInfo = await ThirdPartyEmailPassword.getUserByThirdPartyInfo("public", "custom", "user");

assert.strictEqual(userInfo.email, signUpUserInfo.email);
assert.strictEqual(userInfo.id, signUpUserInfo.id);
Expand Down Expand Up @@ -824,7 +827,10 @@ describe(`signupTest: ${printPath("[test/thirdpartyemailpassword/signupFeature.t

let thirdPartyRecipe = ThirdPartyEmailPasswordRecipe.getInstanceOrThrowError();

assert.strictEqual(await ThirdPartyEmailPassword.getUserByThirdPartyInfo("custom", "user"), undefined);
assert.strictEqual(
await ThirdPartyEmailPassword.getUserByThirdPartyInfo("public", "custom", "user"),
undefined
);

const app = express();

Expand Down Expand Up @@ -858,7 +864,7 @@ describe(`signupTest: ${printPath("[test/thirdpartyemailpassword/signupFeature.t
assert.strictEqual(response.statusCode, 200);

let signUpUserInfo = response.body.user;
let userInfo = await ThirdPartyEmailPassword.getUserByThirdPartyInfo("custom", "user");
let userInfo = await ThirdPartyEmailPassword.getUserByThirdPartyInfo("public", "custom", "user");

assert.strictEqual(userInfo.email, signUpUserInfo.email);
assert.strictEqual(userInfo.id, signUpUserInfo.id);
Expand Down
4 changes: 4 additions & 0 deletions test/thirdpartypasswordless/emailDelivery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartypasswordless/emailDelivery
app.use(errorHandler());

let user = await ThirdpartyPasswordless.thirdPartyManuallyCreateOrUpdateUser(
"public",
"supertokens",
"test-user-id",
"test@example.com"
Expand Down Expand Up @@ -174,6 +175,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartypasswordless/emailDelivery
app.use(errorHandler());

let user = await ThirdpartyPasswordless.thirdPartyManuallyCreateOrUpdateUser(
"public",
"supertokens",
"test-user-id",
"test@example.com"
Expand Down Expand Up @@ -265,6 +267,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartypasswordless/emailDelivery
app.use(errorHandler());

let user = await ThirdpartyPasswordless.thirdPartyManuallyCreateOrUpdateUser(
"public",
"supertokens",
"test-user-id",
"test@example.com"
Expand Down Expand Up @@ -383,6 +386,7 @@ describe(`emailDelivery: ${printPath("[test/thirdpartypasswordless/emailDelivery
app.use(errorHandler());

let user = await ThirdpartyPasswordless.thirdPartyManuallyCreateOrUpdateUser(
"public",
"supertokens",
"test-user-id",
"test@example.com"
Expand Down
4 changes: 2 additions & 2 deletions test/thirdpartypasswordless/getUsersByEmailFeature.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe(`getUsersByEmail: ${printPath("[test/thirdpartypasswordless/getUsersByE
// given there are no users

// when
const thirdPartyUsers = await getUsersByEmail("john.doe@example.com");
const thirdPartyUsers = await getUsersByEmail("public", "john.doe@example.com");

// then
assert.strictEqual(thirdPartyUsers.length, 0);
Expand Down Expand Up @@ -110,7 +110,7 @@ describe(`getUsersByEmail: ${printPath("[test/thirdpartypasswordless/getUsersByE
await thirdPartyManuallyCreateOrUpdateUser("mock", "thirdPartyJohnDoe", "john.doe@example.com");
await thirdPartyManuallyCreateOrUpdateUser("mock2", "thirdPartyDaveDoe", "john.doe@example.com");

const thirdPartyUsers = await getUsersByEmail("john.doe@example.com");
const thirdPartyUsers = await getUsersByEmail("public", "john.doe@example.com");

assert.strictEqual(thirdPartyUsers.length, 2);

Expand Down

0 comments on commit 96baaa7

Please sign in to comment.