Last active
September 12, 2019 13:21
-
-
Save FunnyGhost/89d5e7c615628ca48874972b1d375e77 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('should fail if the backend returns an error 3 times in a row', done => { | |
let bubblesUpTheError = false; | |
serviceUnderTest.getFavoriteMovies().subscribe(() => {}, () => (bubblesUpTheError = true); | |
const req = http.expectOne(environment.favoriteUrl, 'expected to make an initial request'); | |
expect(req.request.method).toEqual('GET'); | |
req.flush('ERROR', { status: 500, statusText: 'Internal server error' }); | |
const req2 = http.expectOne(environment.favoriteUrl, 'expected to make a second request'); | |
expect(req2.request.method).toEqual('GET'); | |
req2.flush('ERROR', { status: 500, statusText: 'Internal server error' }); | |
const req3 = http.expectOne(environment.favoriteUrl, 'exected to make a third request'); | |
expect(req3.request.method).toEqual('GET'); | |
req3.flush('ERROR', { status: 500, statusText: 'Internal server error' }); | |
expect(bubblesUpTheError).toBeTruthy(); | |
http.verify(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment