From 4b6ce80d37a544d1d4258a13b6afeb42dcab9e66 Mon Sep 17 00:00:00 2001 From: Blair Currey <12960453+BlairCurrey@users.noreply.github.com> Date: Mon, 2 Dec 2024 21:57:24 -0500 Subject: [PATCH] fix(auth): return erroneously removed tests --- packages/auth/src/tenant/service.test.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/packages/auth/src/tenant/service.test.ts b/packages/auth/src/tenant/service.test.ts index 3bcab39056..fa553b7b18 100644 --- a/packages/auth/src/tenant/service.test.ts +++ b/packages/auth/src/tenant/service.test.ts @@ -46,6 +46,13 @@ describe('Tenant Service', (): void => { }) expect(tenant.deletedAt).toBe(undefined) }) + + test('fails to create tenant with duplicate id', async (): Promise => { + const tenantData = createTenantData() + await tenantService.create(tenantData) + + await expect(tenantService.create(tenantData)).rejects.toThrow() + }) }) describe('get', (): void => { @@ -89,6 +96,22 @@ describe('Tenant Service', (): void => { }) }) + test('can update partial fields', async (): Promise => { + const tenantData = createTenantData() + const created = await tenantService.create(tenantData) + + const updateData = { + idpConsentUrl: faker.internet.url() + } + + const updated = await tenantService.update(created.id, updateData) + expect(updated).toMatchObject({ + id: created.id, + idpConsentUrl: updateData.idpConsentUrl, + idpSecret: created.idpSecret + }) + }) + test('returns undefined for non-existent tenant', async (): Promise => { const updated = await tenantService.update(faker.string.uuid(), { idpConsentUrl: faker.internet.url() @@ -122,7 +145,6 @@ describe('Tenant Service', (): void => { const deletedTenant = await Tenant.query() .findById(created.id) .whereNotNull('deletedAt') - console.log({ deletedTenant }) expect(deletedTenant).toBeDefined() expect(deletedTenant?.deletedAt).toBeDefined() })