Skip to content

Commit

Permalink
fix: organisation test
Browse files Browse the repository at this point in the history
  • Loading branch information
dainty92 committed Mar 3, 2025
1 parent ae08b28 commit 2538a23
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
7 changes: 2 additions & 5 deletions src/modules/organisations/organisations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,8 @@ export class OrganisationsService {

async getUserOrganisations(userId: string, page: number = 1, page_size: number = 10) {
// const organisations = await this.getAllUserOrganisations(userId);
const [organisations, total_count] = await this.organisationRepository.findAndCount({
where: { isDeleted: false },
skip: (page - 1) * page_size,
take: page_size,
});
const organisations = await this.organisationRepository.findBy({ isDeleted: false });
const total_count = organisations.length;

return {
status_code: HttpStatus.OK,
Expand Down
8 changes: 2 additions & 6 deletions src/modules/organisations/tests/organisations.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,6 @@ describe('OrganisationsService', () => {
});

describe('deleteorganisation', () => {
beforeAll(() => {
console.log(Object.keys(organisationRepository));
});

it('should mark an organisation as deleted', async () => {
const orgId = 'org-id';

Expand Down Expand Up @@ -315,7 +311,7 @@ describe('OrganisationsService', () => {
});

it('should exclude deleted organisations from queries', async () => {
organisationRepository.findAndCount = jest.fn().mockResolvedValue([[], 0]);
organisationRepository.findBy = jest.fn().mockResolvedValue([]);

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

Expand All @@ -331,7 +327,7 @@ describe('OrganisationsService', () => {
});

// ✅ Fix expectation
expect(organisationRepository.findAndCountBy).toHaveBeenCalledWith({
expect(organisationRepository.findBy).toHaveBeenCalledWith({
isDeleted: false,
});
});
Expand Down

0 comments on commit 2538a23

Please sign in to comment.