Skip to content

Commit

Permalink
Initial test implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
markdeluk committed Jan 1, 2024
1 parent a2eb819 commit 6e7f18b
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
2 changes: 0 additions & 2 deletions api/src/availability/availability.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
40 changes: 40 additions & 0 deletions api/src/availability/availability.service.spec.ts
Original file line number Diff line number Diff line change
@@ -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>(AvailabilityService);
});

afterEach(() => jest.clearAllMocks());

/*************** Tests ***************/

it('should be defined', () => {
expect(service).toBeDefined();
});
});

0 comments on commit 6e7f18b

Please sign in to comment.