Created
October 10, 2017 05:25
-
-
Save navix/bab7ed3341e13e1b569acfc5d0cd775d to your computer and use it in GitHub Desktop.
Skip TestBed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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