Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { MusicCatalogService } from '../src/Services/MusicCatalogService';
- import { IMusicRepository } from '../src/Repositories/IMusicRepository';
- import { Track } from '../src/Models/Track';
- describe('MusicCatalogService tests', () => {
- let sut: MusicCatalogService;
- let mockRepo: Track[] = new Array(
- new Track(1, "Mock Title 1", "The Mockers", 0),
- new Track(2, "Mock Title 2", "The Mockers 2", 0)
- );
- it('Should return Tracks value', () => {
- //Arrange
- const Mock = jest.fn<IMusicRepository>(() => ({
- get: jest.fn().mockReturnValue(mockRepo)
- }));
- const mock = new Mock();
- sut = new MusicCatalogService(mock);
- //Act
- var result = sut.get();
- //Assert
- expect(mock.get).toHaveBeenCalled();
- expect(result.length).toBe(2);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement