mirror of
https://github.com/apricote/Listory.git
synced 2026-01-13 21:21:02 +00:00
test: create initial unit tests
This commit is contained in:
parent
be7fb7d13a
commit
e476243b85
16 changed files with 1177 additions and 18 deletions
|
|
@ -1,18 +1,25 @@
|
|||
import { HttpService } from "@nestjs/common";
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { SpotifyApiService } from "./spotify-api.service";
|
||||
|
||||
describe("SpotifyApiService", () => {
|
||||
let service: SpotifyApiService;
|
||||
let httpService: HttpService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [SpotifyApiService],
|
||||
providers: [
|
||||
SpotifyApiService,
|
||||
{ provide: HttpService, useFactory: () => ({}) },
|
||||
],
|
||||
}).compile();
|
||||
|
||||
service = module.get<SpotifyApiService>(SpotifyApiService);
|
||||
httpService = module.get<HttpService>(HttpService);
|
||||
});
|
||||
|
||||
it("should be defined", () => {
|
||||
expect(service).toBeDefined();
|
||||
expect(httpService).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,18 +1,50 @@
|
|||
import { Logger } from "@nestjs/common";
|
||||
import { Test, TestingModule } from "@nestjs/testing";
|
||||
import { ListensService } from "../../listens/listens.service";
|
||||
import { MusicLibraryService } from "../../music-library/music-library.service";
|
||||
import { UsersService } from "../../users/users.service";
|
||||
import { SpotifyApiService } from "./spotify-api/spotify-api.service";
|
||||
import { SpotifyAuthService } from "./spotify-auth/spotify-auth.service";
|
||||
import { SpotifyService } from "./spotify.service";
|
||||
|
||||
describe("SpotifyService", () => {
|
||||
let service: SpotifyService;
|
||||
let usersService: UsersService;
|
||||
let listensService: ListensService;
|
||||
let musicLibraryService: MusicLibraryService;
|
||||
let spotifyApi: SpotifyApiService;
|
||||
let spotifyAuth: SpotifyAuthService;
|
||||
let logger: Logger;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [SpotifyService],
|
||||
providers: [
|
||||
SpotifyService,
|
||||
{ provide: UsersService, useFactory: () => ({}) },
|
||||
{ provide: ListensService, useFactory: () => ({}) },
|
||||
{ provide: MusicLibraryService, useFactory: () => ({}) },
|
||||
{ provide: SpotifyApiService, useFactory: () => ({}) },
|
||||
{ provide: SpotifyAuthService, useFactory: () => ({}) },
|
||||
{ provide: Logger, useValue: new Logger() },
|
||||
],
|
||||
}).compile();
|
||||
|
||||
service = module.get<SpotifyService>(SpotifyService);
|
||||
usersService = module.get<UsersService>(UsersService);
|
||||
listensService = module.get<ListensService>(ListensService);
|
||||
musicLibraryService = module.get<MusicLibraryService>(MusicLibraryService);
|
||||
spotifyApi = module.get<SpotifyApiService>(SpotifyApiService);
|
||||
spotifyAuth = module.get<SpotifyAuthService>(SpotifyAuthService);
|
||||
logger = module.get<Logger>(Logger);
|
||||
});
|
||||
|
||||
it("should be defined", () => {
|
||||
expect(service).toBeDefined();
|
||||
expect(usersService).toBeDefined();
|
||||
expect(listensService).toBeDefined();
|
||||
expect(musicLibraryService).toBeDefined();
|
||||
expect(spotifyApi).toBeDefined();
|
||||
expect(spotifyAuth).toBeDefined();
|
||||
expect(logger).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue