Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
describe('FavoriteMoviesService', () => {
let serviceUnderTest: FavoriteMoviesService;
let http: HttpTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [FavoriteMoviesService]
});
serviceUnderTest = TestBed.get(FavoriteMoviesService);
http = TestBed.get(HttpTestingController);
});
it('should return the favorite movies from the backend', () => {
let result: Movie[] = [];
serviceUnderTest.getFavoriteMovies().subscribe(data => {
result = data;
});
const req = http.expectOne(environment.favoriteUrl);
expect(req.request.method).toEqual('GET');
req.flush(moviesToUse);
http.verify();
});
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.