I have a service called AlertService which has two properties of type Alert (of the Ionic framework). I want to implement tests for this service but I don't want to use the framework classes for simplification reasons. So I would like to mock the AlertController and Alert classes to test my AlertService. My idea would be to implement such a class in replacement of the Alert one (of Ionic):
class AlertMock {
opts: Object;
presented: boolean;
constructor(opts) {
this.opts = opts;
this.presented = false;
}
present() {
this.presented = true;
}
dismiss() {
this.presented = false;
}
}
How can I do that ? Knowing that my AlertService references the Alert class of Ionic.
Aucun commentaire:
Enregistrer un commentaire