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