I'm trying to create a spec.ts
for my application. Sadly this is using the LoadingController from ionic-angular
. Now when I'm trying to configure the module, I will need to provide it with the LoadingController (since it's in the constructor of the module).
The problem I'm currently running into is that the LoadingController wants to be provided with a App
object/instance. (_app: App
params)
I was desperate so I asked Ionic themselves. github #8539
But they closed my question because it was a question and not an issue, although I'm having issues realizing it which they haven't responded to. It would be a shame if this is impossible/no one knows how, since it's a pretty cool feature and it affects not just the LoadingController, f.e. the AlertController and ToastController are affected by this as well.
My testbed configuration atm:
TestBed.configureTestingModule({
declarations: [EventsPage],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
providers: [
{provide: APICaller, useValue: mockAPICaller},
{provide: NavController, useValue: mockNavController },
{provide: LoadingController, useValue: ???????}, //it seems like everything I try to enter here fails.
],
imports: [FormsModule]
});
And the EventsPage constructor:
constructor(public apiCaller: APICaller, public navCtrl: NavController,
public loadingCtrl: LoadingController){}
EDIT: usage of LoadingController
getEvents() {
// setup a loadingscreen
let loading = this.loadingCtrl.create({
content: "Loading..."
});
// present the loadingscreen
loading.present();
// reset the noEvents boolean.
this.noEvents = true;
// call the api and get all events
this.apiCaller.getEvents()
.subscribe(response => {
// response is list of events
this.events = response;
// if the event is not empty, set noEvents to false.
if (this.events.length > 0) {
this.noEvents = false;
}
// close the loading message.
loading.dismiss();
});
}
Which will then result in this loadingspinner (with different text)