Add extra tests

This commit is contained in:
Adria Navarro 2024-07-03 11:14:30 +02:00
parent 6510a47c06
commit 8372632579
1 changed files with 15 additions and 0 deletions

View File

@ -38,6 +38,7 @@ describe("UserDB", () => {
email, email,
tenantId: config.getTenantId(), tenantId: config.getTenantId(),
}) })
await config.doInTenant(async () => { await config.doInTenant(async () => {
const saveUserResponse = await db.save(user) const saveUserResponse = await db.save(user)
@ -53,4 +54,18 @@ describe("UserDB", () => {
}) })
}) })
}) })
it("the same email cannot be used twice in the same tenant", async () => {
const email = generator.email({})
const user: User = structures.users.user({
email,
tenantId: config.getTenantId(),
})
await config.doInTenant(() => db.save(user))
await config.doInTenant(() =>
expect(db.save(user)).rejects.toThrow(`Email already in use: '${email}'`)
)
})
}) })