Files
wgenerator/src/app/modules/songs/services/song.service.spec.ts
2021-05-21 20:17:26 +02:00

36 lines
861 B
TypeScript

import {TestBed, waitForAsync} from '@angular/core/testing';
import {SongService} from './song.service';
import {SongDataService} from './song-data.service';
import {of} from 'rxjs';
describe('SongService', () => {
const songs = [{title: 'title1'}];
const mockSongDataService = {
list: () => of(songs),
};
beforeEach(
() =>
void TestBed.configureTestingModule({
providers: [{provide: SongDataService, useValue: mockSongDataService}],
})
);
it('should be created', () => {
const service: SongService = TestBed.inject(SongService);
void expect(service).toBeTruthy();
});
it(
'should list songs',
waitForAsync(() => {
const service: SongService = TestBed.inject(SongService);
service.list$().subscribe(s => {
void expect(s[0].title).toEqual('title1');
});
})
);
});