show component
This commit is contained in:
37
src/app/modules/shows/services/show.service.spec.ts
Normal file
37
src/app/modules/shows/services/show.service.spec.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import {TestBed} from '@angular/core/testing';
|
||||
|
||||
import {ShowService} from './show.service';
|
||||
import {ShowDataService} from './show-data.service';
|
||||
|
||||
describe('ShowService', () => {
|
||||
const mockShowDataService = {add: Promise.resolve(null)};
|
||||
beforeEach(() => TestBed.configureTestingModule({
|
||||
providers: [
|
||||
{provide: ShowDataService, useValue: mockShowDataService}
|
||||
]
|
||||
}));
|
||||
|
||||
ShowService.SHOW_TYPE_PUBLIC.forEach(type => {
|
||||
it('should calc public flag for ' + type, async () => {
|
||||
const service: ShowService = TestBed.get(ShowService);
|
||||
const addSpy = spyOn(TestBed.inject(ShowDataService), 'add').and.returnValue(Promise.resolve('id'));
|
||||
|
||||
const id = await service.new$({showType: type});
|
||||
|
||||
expect(id).toBe('id');
|
||||
expect(addSpy).toHaveBeenCalledWith({showType: type, public: true});
|
||||
});
|
||||
});
|
||||
|
||||
ShowService.SHOW_TYPE_PRIVATE.forEach(type => {
|
||||
it('should calc private flag for ' + type, async () => {
|
||||
const service: ShowService = TestBed.get(ShowService);
|
||||
const addSpy = spyOn(TestBed.inject(ShowDataService), 'add').and.returnValue(Promise.resolve('id'));
|
||||
|
||||
const id = await service.new$({showType: type});
|
||||
|
||||
expect(id).toBe('id');
|
||||
expect(addSpy).toHaveBeenCalledWith({showType: type, public: false});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user