login
This commit is contained in:
47
src/app/modules/songs/song-list/song-list.component.spec.ts
Normal file
47
src/app/modules/songs/song-list/song-list.component.spec.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import {async, ComponentFixture, fakeAsync, TestBed, tick} from '@angular/core/testing';
|
||||
|
||||
import {SongListComponent} from './song-list.component';
|
||||
import {of} from 'rxjs';
|
||||
import {SongService} from '../services/song.service';
|
||||
import {NO_ERRORS_SCHEMA} from '@angular/core';
|
||||
|
||||
describe('SongListComponent', () => {
|
||||
let component: SongListComponent;
|
||||
let fixture: ComponentFixture<SongListComponent>;
|
||||
|
||||
const songs = [
|
||||
{title: 'title1'}
|
||||
];
|
||||
|
||||
const mockSongService = {
|
||||
list: () => of(songs)
|
||||
};
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [SongListComponent],
|
||||
providers: [
|
||||
{provide: SongService, useValue: mockSongService}
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SongListComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should read songs from SongService', fakeAsync(() => {
|
||||
tick();
|
||||
expect(component.songs$).toEqual([
|
||||
{title: 'title1'}
|
||||
] as any);
|
||||
}));
|
||||
});
|
||||
Reference in New Issue
Block a user