Clean tests

This commit is contained in:
adrinr 2023-02-03 09:54:25 +00:00
parent 682b0a8401
commit 2e18506e77
3 changed files with 22 additions and 20 deletions

View File

@ -1,7 +1,9 @@
jest.mock("nodemailer") jest.mock("nodemailer")
import { TestConfiguration, mocks } from "../../../../tests" import { TestConfiguration, mocks, } from "../../../../tests"
const sendMailMock = mocks.email.mock() const sendMailMock = mocks.email.mock()
import { events, tenancy, utils } from "@budibase/backend-core" import { events, tenancy } from "@budibase/backend-core"
import { structures } from "@budibase/backend-core/tests"
const expectSetAuthCookie = (res: any) => { const expectSetAuthCookie = (res: any) => {
expect( expect(
@ -26,7 +28,7 @@ describe("/api/global/auth", () => {
describe("password", () => { describe("password", () => {
describe("POST /api/global/auth/:tenantId/login", () => { describe("POST /api/global/auth/:tenantId/login", () => {
it("should login", () => {}) it("should login", () => { })
}) })
describe("POST /api/global/auth/logout", () => { describe("POST /api/global/auth/logout", () => {
@ -41,7 +43,7 @@ describe("/api/global/auth", () => {
describe("POST /api/global/auth/:tenantId/reset", () => { describe("POST /api/global/auth/:tenantId/reset", () => {
it("should generate password reset email", async () => { it("should generate password reset email", async () => {
await tenancy.doInTenant(config.tenant1User!.tenantId, async () => { await tenancy.doInTenant(config.tenant1User!.tenantId, async () => {
const userEmail = `${utils.newid()}@test.com` const userEmail = structures.email()
const { res, code } = await config.api.auth.requestPasswordReset( const { res, code } = await config.api.auth.requestPasswordReset(
sendMailMock, sendMailMock,
userEmail userEmail
@ -63,7 +65,7 @@ describe("/api/global/auth", () => {
describe("POST /api/global/auth/:tenantId/reset/update", () => { describe("POST /api/global/auth/:tenantId/reset/update", () => {
it("should reset password", async () => { it("should reset password", async () => {
await tenancy.doInTenant(config.tenant1User!.tenantId, async () => { await tenancy.doInTenant(config.tenant1User!.tenantId, async () => {
const userEmail = `${utils.newid()}@test.com` const userEmail = structures.email()
const { code } = await config.api.auth.requestPasswordReset( const { code } = await config.api.auth.requestPasswordReset(
sendMailMock, sendMailMock,
userEmail userEmail
@ -83,35 +85,35 @@ describe("/api/global/auth", () => {
}) })
describe("init", () => { describe("init", () => {
describe("POST /api/global/auth/init", () => {}) describe("POST /api/global/auth/init", () => { })
describe("GET /api/global/auth/init", () => {}) describe("GET /api/global/auth/init", () => { })
}) })
describe("datasource", () => { describe("datasource", () => {
// MULTI TENANT // MULTI TENANT
describe("GET /api/global/auth/:tenantId/datasource/:provider", () => {}) describe("GET /api/global/auth/:tenantId/datasource/:provider", () => { })
describe("GET /api/global/auth/:tenantId/datasource/:provider/callback", () => {}) describe("GET /api/global/auth/:tenantId/datasource/:provider/callback", () => { })
// SINGLE TENANT // SINGLE TENANT
describe("GET /api/global/auth/datasource/:provider/callback", () => {}) describe("GET /api/global/auth/datasource/:provider/callback", () => { })
}) })
describe("google", () => { describe("google", () => {
// MULTI TENANT // MULTI TENANT
describe("GET /api/global/auth/:tenantId/google", () => {}) describe("GET /api/global/auth/:tenantId/google", () => { })
describe("GET /api/global/auth/:tenantId/google/callback", () => {}) describe("GET /api/global/auth/:tenantId/google/callback", () => { })
// SINGLE TENANT // SINGLE TENANT
describe("GET /api/global/auth/google/callback", () => {}) describe("GET /api/global/auth/google/callback", () => { })
describe("GET /api/admin/auth/google/callback", () => {}) describe("GET /api/admin/auth/google/callback", () => { })
}) })
describe("oidc", () => { describe("oidc", () => {
@ -176,10 +178,10 @@ describe("/api/global/auth", () => {
// SINGLE TENANT // SINGLE TENANT
describe("GET /api/global/auth/oidc/callback", () => {}) describe("GET /api/global/auth/oidc/callback", () => { })
describe("GET /api/global/auth/oidc/callback", () => {}) describe("GET /api/global/auth/oidc/callback", () => { })
describe("GET /api/admin/auth/oidc/callback", () => {}) describe("GET /api/admin/auth/oidc/callback", () => { })
}) })
}) })

View File

@ -6,7 +6,7 @@ import { EmailTemplatePurpose } from "../../../../constants"
describe("/api/global/email", () => { describe("/api/global/email", () => {
const config = new TestConfiguration() const config = new TestConfiguration()
beforeEach(async () => { beforeAll(async () => {
await config.beforeAll() await config.beforeAll()
}) })

View File

@ -3,7 +3,7 @@ import { InviteUsersResponse, User } from "@budibase/types"
jest.mock("nodemailer") jest.mock("nodemailer")
import { TestConfiguration, mocks, structures } from "../../../../tests" import { TestConfiguration, mocks, structures } from "../../../../tests"
const sendMailMock = mocks.email.mock() const sendMailMock = mocks.email.mock()
import { context, events, tenancy, utils } from "@budibase/backend-core" import { context, events, tenancy } from "@budibase/backend-core"
describe("/api/global/users", () => { describe("/api/global/users", () => {
const config = new TestConfiguration() const config = new TestConfiguration()
@ -443,7 +443,7 @@ describe("/api/global/users", () => {
}) })
it("should not be able to update email address", async () => { it("should not be able to update email address", async () => {
const email = `${utils.newid()}@test.com` const email = structures.email()
const user = await config.createUser(structures.users.user({ email })) const user = await config.createUser(structures.users.user({ email }))
user.email = "new@test.com" user.email = "new@test.com"