-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(organization): remove domain email (#598)
- Loading branch information
1 parent
f083113
commit 521ac37
Showing
7 changed files
with
117 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/~/organizations/lib/src/usecase/RemoveDomainEmailById.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// | ||
|
||
import { schema } from "@~/moncomptepro.database"; | ||
import { create_unicorn_organization } from "@~/moncomptepro.database/seed/unicorn"; | ||
import { empty_database, migrate, pg } from "@~/moncomptepro.database/testing"; | ||
import { beforeAll, beforeEach, expect, test } from "bun:test"; | ||
import { RemoveDomainEmailById } from "./RemoveDomainEmailById"; | ||
|
||
// | ||
|
||
beforeAll(migrate); | ||
beforeEach(empty_database); | ||
|
||
const remove_domain_email_by_id = RemoveDomainEmailById({ pg }); | ||
|
||
// | ||
|
||
test("returns no membership", async () => { | ||
const organization_id = await create_unicorn_organization(pg); | ||
const [{ domain_id }] = await pg | ||
.insert(schema.email_domains) | ||
.values({ | ||
domain: "unicorn.xyz", | ||
organization_id, | ||
}) | ||
.returning({ domain_id: schema.email_domains.id }); | ||
|
||
await remove_domain_email_by_id(domain_id); | ||
|
||
expect( | ||
await pg.query.email_domains.findFirst({ | ||
columns: { id: true }, | ||
where: (table, { eq }) => eq(table.id, domain_id), | ||
}), | ||
).toBeUndefined(); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/~/organizations/lib/src/usecase/RemoveDomainEmailById.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
|
||
import { | ||
schema, | ||
type MonCompteProDatabaseCradle, | ||
} from "@~/moncomptepro.database"; | ||
import { eq } from "drizzle-orm"; | ||
|
||
// | ||
|
||
export function RemoveDomainEmailById({ pg }: MonCompteProDatabaseCradle) { | ||
return async function remove_domain_email_by_id(id: number) { | ||
return pg | ||
.delete(schema.email_domains) | ||
.where(eq(schema.email_domains.id, id)); | ||
}; | ||
} | ||
|
||
export type RemoveDomainEmailByIdHandler = ReturnType< | ||
typeof RemoveDomainEmailById | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// | ||
|
||
export * from "./RemoveDomainEmailById"; |