Skip to content

Instantly share code, notes, and snippets.

@FunnyGhost
Created September 12, 2019 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FunnyGhost/de670fa5ee54c2d7f604548ef16b81b7 to your computer and use it in GitHub Desktop.
Save FunnyGhost/de670fa5ee54c2d7f604548ef16b81b7 to your computer and use it in GitHub Desktop.
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