This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit a9b7d07e authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Fixing Tests

parent ca58d1bd
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { GitsearchTestModule } from '../../test.module';
import { BookmarkComponent } from 'app/bookmarks/bookmarks.component';
import { IUserWatchList, UserWatchList } from 'app/shared/model/user-watch-list.model';
import { IUserWatchList } from 'app/shared/model/user-watch-list.model';
import { UserWatchListService } from 'app/entities/user-watch-list/user-watch-list.service';
import { CheckFrequency } from 'app/shared/model/enumerations/check-frequency.model';
import { of } from 'rxjs';
describe('Component Tests', () => {
describe('Bookmarks Component', () => {
let comp: BookmarkComponent;
let fixture: ComponentFixture<BookmarkComponent>;
let userWatchListService: UserWatchListService;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [GitsearchTestModule],
declarations: [BookmarkComponent],
})
.overrideTemplate(BookmarkComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(BookmarkComponent);
comp = fixture.componentInstance;
userWatchListService = fixture.debugElement.injector.get(UserWatchListService);
describe('Bookmarks Component', () => {
let comp: BookmarkComponent;
let fixture: ComponentFixture<BookmarkComponent>;
let userWatchListService: UserWatchListService;
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [GitsearchTestModule],
declarations: [BookmarkComponent],
})
.overrideTemplate(BookmarkComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(BookmarkComponent);
comp = fixture.componentInstance;
userWatchListService = fixture.debugElement.injector.get(UserWatchListService);
});
const defaultWatchList: IUserWatchList[] = [{
id: 1,
name: "My WatchList",
checkFrequency: CheckFrequency.NEVER,
userLogin: "any",
userId: 0
}];
it('Should call userWatchListService.findMyWatchlists on initial ngOnInit', () => {
// GIVEN
spyOn(userWatchListService, 'findMyWatchlists').and.returnValue(of({ body: defaultWatchList }))
// WHEN,
comp.ngOnInit();
// THEN
expect(userWatchListService.findMyWatchlists).toHaveBeenCalled();
});
});
let defaultWatchList: IUserWatchList[] = [{
id: 1,
name: "My WatchList",
checkFrequency: CheckFrequency.NEVER,
userLogin: "any",
userId: 0
}];
it('Should call userWatchListService.findMyWatchlists on initial ngOnInit', () => {
// GIVEN
spyOn(userWatchListService, 'findMyWatchlists').and.returnValue(of({body: defaultWatchList}))
// WHEN,
comp.ngOnInit();
// THEN
expect(userWatchListService.findMyWatchlists).toHaveBeenCalled();
});
});
});
......@@ -53,10 +53,12 @@ import { TranslateService } from '@ngx-translate/core';
provide: AccountService,
useClass: MockAccountService,
},
/* disabled here. Mocking is done in test cases
{
provide: UserWatchListService,
useClass: MockUserWatchListService,
},
*/
{
provide: LoginModalService,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment