Created
October 1, 2020 02:07
-
-
Save Qarun-Qadir-Bissoondial/ab303fa5fbca7abe65a089bf97099065 to your computer and use it in GitHub Desktop.
Testing 500 status response
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
fdescribe('getAllTodos', () => { | |
it('should return an empty array if an Interal Server Error occurs', (done) => { | |
service.getAllTodos().subscribe( | |
(data: Todo[]) => { | |
expect(data).toBeDefined(); | |
expect(Array.isArray(data)).toBe(true); | |
expect(data.length).toBe(0); | |
done() | |
}, | |
(error: HttpErrorResponse) => { fail('The request was supposed to return an empty array') } | |
); | |
const testRequest = httpMock.expectOne('https://jsonplaceholder.typicode.com/todos'); | |
expect(testRequest.request.method).toBe('GET'); | |
testRequest.flush({}, { status: 500, statusText: 'Internal Server Error' }); | |
}) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment