Skip to content

Commit

Permalink
test: organization delete
Browse files Browse the repository at this point in the history
  • Loading branch information
IanFonzie committed Jun 28, 2024
1 parent b272691 commit b9f559e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/back-end/integration/resources/organization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { agent } from "supertest";
import { buildOrganization } from "tests/utils/generate/organization";
import { buildCreateUserParams } from "tests/utils/generate/user";
import { adt } from "shared/lib/types";
import { MembershipType } from "shared/lib/resources/affiliation";

async function setup() {
const [testUser1, testUser1Session] = await insertUserWithActiveSession(
Expand Down Expand Up @@ -63,6 +64,8 @@ const endpoint = "/api/organizations";

test("organization crud", async () => {
const {
testUser1,
testUser2,
testUser1Session,
testUser2Session,
testAdminSession,
Expand Down Expand Up @@ -187,6 +190,29 @@ test("organization crud", async () => {
const readManyBeforeDeleteResult = await adminAppAgent.get(
`${endpoint}?page=1&pageSize=50`
);

expect(readManyBeforeDeleteResult.status).toEqual(200);
expect(readManyBeforeDeleteResult.body.items).toHaveLength(2);

// Add affiliation to test deletion with events
await user1AppAgent.post("/api/affiliations").send({
userEmail: testUser2.email,
organization: organizationId,
membershipType: MembershipType.Member
});

const deleteResult = await user1AppAgent.delete(organizationIdUrl);

expect(deleteResult.status).toEqual(200);
expect(deleteResult.body).toMatchObject({
...qualifyServiceAreasResult.body,
possessAllCapabilities: false, // Don't think this is specified anywhere
active: false,
deactivatedOn: expect.any(String),
deactivatedBy: testUser1.id,
updatedAt: expect.any(String)
});

const readDeletedResult = await user1AppAgent.get(organizationIdUrl);
expect(readDeletedResult.status).toEqual(404);
});

0 comments on commit b9f559e

Please sign in to comment.