Skip to content

Commit

Permalink
fix: test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
dainty92 committed Mar 3, 2025
1 parent 1294c11 commit 291ccd2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/modules/organisations/tests/organisations.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,21 @@ describe('OrganisationsService', () => {
state: 'Active',
city: 'Lagos',
zipCode: '100001',
products: [], // Add empty array for products
preferences: {}, // Add empty object for preferences
invites: [], // Add empty array for invites
products: [],
preferences: {},
invites: [],
created_at: new Date(),
updated_at: new Date(),
} as unknown as Partial<Organisation> as Organisation);

const result = await service.deleteorganisation(orgId);

expect(result).toEqual({ message: 'Organisation deleted successfully' });
expect(organisationRepository.update).toHaveBeenCalledWith({ id: orgId }, { isDeleted: true });

// Check if the entity was marked as deleted
// ✅ Fix expectation
expect(organisationRepository.update).toHaveBeenCalledWith(orgId, { isDeleted: true });

// ✅ Check if organisation was marked as deleted
const updatedOrg = await organisationRepository.findOneBy({ id: orgId });
expect(updatedOrg?.isDeleted).toBe(true);
});
Expand All @@ -315,10 +317,9 @@ describe('OrganisationsService', () => {

expect(result).toEqual({ organisations: [], total_count: 0 });

expect(organisationRepository.findAndCount).toHaveBeenCalledWith({
where: { isDeleted: false },
skip: expect.any(Number),
take: expect.any(Number),
// ✅ Fix expectation
expect(organisationRepository.findAndCountBy).toHaveBeenCalledWith({
isDeleted: false,
});
});
});
Expand Down

0 comments on commit 291ccd2

Please sign in to comment.