Skip to content

Instantly share code, notes, and snippets.

@navix
Created October 10, 2017 05:25
Show Gist options
  • Select an option

  • Save navix/bab7ed3341e13e1b569acfc5d0cd775d to your computer and use it in GitHub Desktop.

Select an option

Save navix/bab7ed3341e13e1b569acfc5d0cd775d to your computer and use it in GitHub Desktop.
Skip TestBed
describe('Quote Service', () => {
let mockApiService: ApiService;
let quoteService: QuoteService;
let mockResponse = [ ... ]; // mock todos response
beforeEach(() => {
mockApiService = { get: null } as ApiService;
spyOn(mockApiService, 'get').and.returnValue(Observable.of({
json: () => mockResponse
}));
quoteService = new QuoteService(mockApiService);
});
it('should get to dos', () =>
QuoteService.getTodos()
.subscribe(res => {
expect(mockApiService.get).toHaveBeenCalledWith('/todos');
expect(res).toEqual(mockResponse);
});
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment