Last active
October 1, 2020 00:08
-
-
Save Qarun-Qadir-Bissoondial/93bcc8c7657eb32f0b0df91c2e34a877 to your computer and use it in GitHub Desktop.
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('createTodo should send a POST request and return the newly created item', (done) => { | |
const item: Todo = { | |
id: 2, | |
userId: 2, | |
title: 'Walk dog', | |
completed: false | |
}; | |
service.createTodo(item).subscribe( | |
(data: Todo) => { | |
expect(data).toBeDefined(); | |
expect(data).toEqual(item); | |
done() | |
}, | |
(error) => { | |
fail(error.message) | |
} | |
); | |
const testRequest = httpMock.expectOne('https://jsonplaceholder.typicode.com/todos'); | |
expect(testRequest.request.method).toBe('POST'); | |
testRequest.flush(item); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment