Skip to content

Commit

Permalink
fix: organisations.service.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
dainty92 committed Mar 3, 2025
1 parent 14b6632 commit 26be27f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/modules/organisations/tests/organisations.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,10 @@ describe('OrganisationsService', () => {
describe('deleteorganisation', () => {
it('should mark an organisation as deleted', async () => {
const orgId = 'org-id';
const mockOrganisation = { id: orgId, isDeleted: false } as Organisation;

// Ensure `findOneBy` is mocked correctly
jest.spyOn(organisationRepository, 'findOneBy').mockResolvedValue(mockOrganisation);
jest.spyOn(organisationRepository, 'update').mockResolvedValue({ affected: 1 } as any);
// Mock repository functions
organisationRepository.update = jest.fn().mockResolvedValue({ affected: 1 });
organisationRepository.findOneBy = jest.fn().mockResolvedValue({ id: orgId, isDeleted: true });

const result = await service.deleteorganisation(orgId);

Expand All @@ -287,8 +286,8 @@ describe('OrganisationsService', () => {
{ id: 'org2', name: 'Deleted Org', isDeleted: true },
] as Organisation[];

// Ensure `findBy` is mocked instead of `find`
jest.spyOn(organisationRepository, 'findBy').mockResolvedValue(mockOrganisations.filter(org => !org.isDeleted));
// Mock `findBy` to only return non-deleted organisations
organisationRepository.findBy = jest.fn().mockResolvedValue(mockOrganisations.filter(org => !org.isDeleted));

const result = await service.getUserOrganisations('test-user-id');

Expand Down

0 comments on commit 26be27f

Please sign in to comment.