Skip to content

Commit

Permalink
added di unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolovlazar committed Aug 27, 2024
1 parent 3a550b4 commit 0c7c8f1
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/unit/di.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import "reflect-metadata";

import {
destroyContainer,
getInjection,
initializeContainer,
} from "@/di/container";
import { MockTodosRepository } from "@/src/infrastructure/repositories/todos.repository.mock";
import { MockUsersRepository } from "@/src/infrastructure/repositories/users.repository.mock";
import { MockAuthenticationService } from "@/src/infrastructure/services/authentication.service.mock";
import { afterEach, beforeEach, expect, it } from "vitest";

beforeEach(() => {
initializeContainer();
});

afterEach(() => {
destroyContainer();
});

it("should use Mock versions of repos and services", async () => {
const authService = getInjection("IAuthenticationService");
expect(authService).toBeInstanceOf(MockAuthenticationService);

const usersRepository = getInjection("IUsersRepository");
expect(usersRepository).toBeInstanceOf(MockUsersRepository);

const todosRepository = getInjection("ITodosRepository");
expect(todosRepository).toBeInstanceOf(MockTodosRepository);
});

0 comments on commit 0c7c8f1

Please sign in to comment.