IMPORTANT note is the brackets after the inject call. For example.
inject(function(someServices) {
If you look at the inject type:
export declare function inject(tokens: any[], fn: Function): () => any;
You can see that it returns a function, so you are not getting output because you forgot to call the function !!
If you think about it, it makes sense that it returns a function, because it performs a function!
Therefore, additional partners must solve the whole problem!
Working example:
it('should allow you to observe for changes', function(done) { inject([GlobalStateService], (globalStateService: GlobalStateService) => { globalStateService.observe("user", storageType.InMemoryStorage, (user: string) => { expect(user).toBe("bla"); done(); }); globalStateService.write({ user: "bla"}, storageType.InMemoryStorage); })(); });
Arie Milner Sep 20 '16 at 21:34 2016-09-20 21:34
source share