Created
September 12, 2019 13:29
-
-
Save FunnyGhost/9c5bdb4cb286e3c43b8418d230e36be8 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 return the list of favorite movies if the backend returns an error 2 times and the succeds', () => { | |
let favoriteMovies: Movie[] = []; | |
serviceUnderTest.getFavoriteMovies().subscribe(data => { | |
favoriteMovies = data; | |
}); | |
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 req1 = http.expectOne(environment.favoriteUrl, 'expected to make a second request'); | |
expect(req1.request.method).toEqual('GET'); | |
req1.flush('ERROR', { status: 500, statusText: 'Internal server error' }); | |
const req2 = http.expectOne(environment.favoriteUrl, 'exected to make a third request'); | |
expect(req2.request.method).toEqual('GET'); | |
req2.flush(moviesToUse); | |
expect(favoriteMovies).toEqual(moviesToUse); | |
http.verify(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment