Last active
September 30, 2020 23:53
-
-
Save Qarun-Qadir-Bissoondial/d3a8a4493399646271f89614273bbeb3 to your computer and use it in GitHub Desktop.
Testing simple Get request
This file contains 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
it('getSingleTodo should send a GET request and return a single item', (done) => { | |
service.getSingleTodo(1).subscribe( | |
(item: Todo) => { expect(item).toBeDefined(); done(); }, | |
(error) => { fail(error.message) } | |
); | |
const testRequest = httpMock.expectOne('https://jsonplaceholder.typicode.com/todos/1'); | |
expect(testRequest.request.method).toBe('GET'); | |
testRequest.flush({ id: 1, userId: 1, title: 'Test Todo', completed: false }); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment