Hello everyone,
I started writing tests for our application. For the most of the components we use the onPageLoaded
event, as the content has to be cached.
Now my question is, how do I get into the onPageLoaded
event and mock what is in there? That is a sample code I would like to unit test:
@Component({
templateUrl: "build/pages/subjects/subjects.html"
})
export class SubjectsComponent extends ComponentBase<SubjectModel> {
constructor(nav: NavController, params: NavParams, backendService: BackendService) {
super(nav, params, backendService);
}
public selectSubject(target: string) {
this.nav.push(TopicsComponent, { target: target });
}
protected onPageLoaded(): void {
this.loadNavigation("a0000000", (condition) => {
let model = new SubjectModel();
model.title = condition.title;
model.target = condition.target;
this.models.push(model);
});
}
}
The loadNavigation() method is in the base class. It calls a backend service which I would like to mock.
Any one has already done this here?