Skip to content

Instantly share code, notes, and snippets.

@Qarun-Qadir-Bissoondial
Last active September 30, 2020 23:53
Show Gist options
  • Save Qarun-Qadir-Bissoondial/d3a8a4493399646271f89614273bbeb3 to your computer and use it in GitHub Desktop.
Save Qarun-Qadir-Bissoondial/d3a8a4493399646271f89614273bbeb3 to your computer and use it in GitHub Desktop.
Testing simple Get request
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