Skip to content

Instantly share code, notes, and snippets.

@cyrilletuzi
Last active July 18, 2017 08:39
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 cyrilletuzi/bd8d23edf4716882242563b93318943d to your computer and use it in GitHub Desktop.
Save cyrilletuzi/bd8d23edf4716882242563b93318943d to your computer and use it in GitHub Desktop.
import { TestBed, inject } from '@angular/core/testing';
import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
import { HttpClient } from '@angular/common/http';
import { CinemaService } from './cinema.service';
import { Theater } from '../models/index';
describe('CinemaService', () => {
let theaters: Theater[];
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [CinemaService]
});
});
it('should contain theaters data', inject([CinemaService, HttpClient, HttpTestingController],
(service: CinemaService, http: HttpClient, httpMock: HttpTestingController) => {
service.getTheaters().subscribe((data) => {
expect(data[0].id).toEqual(1);
});
theaters = [
{
id: 1,
title: `Test`,
address: `test`,
logo: {
src: 'static/images/theaters/test.png'
}
}
];
const req = httpMock.expectOne('/api/theaters');
req.flush(theaters);
httpMock.verify();
}));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment