How would I mock the call to a method of a singleton, like:
Foo.get().getBar();
It seems straightforward to mock Foo.getBar(); with
jasmine.createSpyObj(Foo, ['get']);
Foo.get.and.returnValue();
But I've been noodling with dependency injection and can't quite get it to work just right. FWIW: getBar returns a promise, so I'm really trying to mock Foo.get().getBar().then() which I imagine must be something like
Foo.get.getBar.and.callFake(() => { return deferred.promise; });
Aucun commentaire:
Enregistrer un commentaire