More tests

This commit is contained in:
Adria Navarro 2024-07-03 11:59:12 +02:00
parent 8372632579
commit 4ddd450a89
1 changed files with 15 additions and 0 deletions

View File

@ -68,4 +68,19 @@ describe("UserDB", () => {
expect(db.save(user)).rejects.toThrow(`Email already in use: '${email}'`)
)
})
it("the same email cannot be used twice in different tenants", async () => {
const email = generator.email({})
const user: User = structures.users.user({
email,
tenantId: config.getTenantId(),
})
await config.doInTenant(() => db.save(user))
config.newTenant()
await config.doInTenant(() =>
expect(db.save(user)).rejects.toThrow(`Email already in use: '${email}'`)
)
})
})