From 6e7f18bf13bf8e31a1ead68dcd47bcb534648340 Mon Sep 17 00:00:00 2001 From: Marco De Luca <31864038+markdeluk@users.noreply.github.com> Date: Mon, 1 Jan 2024 16:25:22 +0100 Subject: [PATCH] Initial test implementation --- .../availability.controller.spec.ts | 2 - .../availability/availability.service.spec.ts | 40 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 api/src/availability/availability.service.spec.ts diff --git a/api/src/availability/availability.controller.spec.ts b/api/src/availability/availability.controller.spec.ts index 8427a2d..476f07d 100644 --- a/api/src/availability/availability.controller.spec.ts +++ b/api/src/availability/availability.controller.spec.ts @@ -2,8 +2,6 @@ import { testDate } from '@mocks/data'; import { AvailabilityController } from './availability.controller'; import { AvailabilityService } from './availability.service'; import { TestBed } from '@automock/jest'; -import { createMockAbility } from '@hkrecruitment/shared/abilities.spec'; -import { Action } from '@hkrecruitment/shared'; describe('AvailabilityController', () => { let controller: AvailabilityController; diff --git a/api/src/availability/availability.service.spec.ts b/api/src/availability/availability.service.spec.ts new file mode 100644 index 0000000..330f32d --- /dev/null +++ b/api/src/availability/availability.service.spec.ts @@ -0,0 +1,40 @@ +import { testDate } from '@mocks/data'; +import { Test, TestingModule } from '@nestjs/testing'; +import { AvailabilityService } from './availability.service'; +import { Availability } from './availability.entity'; +import { getRepositoryToken } from '@nestjs/typeorm'; +import { mockedRepository } from '@mocks/repositories'; + +describe('AvailabilityService', () => { + let service: AvailabilityService; + + /************* Test setup ************/ + + beforeAll(() => { + jest + .spyOn(global, 'Date') + .mockImplementation(() => testDate as unknown as string); + }); + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [ + AvailabilityService, + { + provide: getRepositoryToken(Availability), + useValue: mockedRepository, + }, + ], + }).compile(); + + service = module.get(AvailabilityService); + }); + + afterEach(() => jest.clearAllMocks()); + + /*************** Tests ***************/ + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +});