Skip to content

Instantly share code, notes, and snippets.

@AntonGorelov
Last active May 4, 2020 11:04
Show Gist options
  • Save AntonGorelov/69dcdc830153d4ec3ebf9b8fbb750433 to your computer and use it in GitHub Desktop.
Save AntonGorelov/69dcdc830153d4ec3ebf9b8fbb750433 to your computer and use it in GitHub Desktop.
describe('TaskApiService', () => {
let httpClient: HttpClient;
let taskApiService: TaskApiService;
let httpTestingController: HttpTestingController;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [HttpClientTestingModule],
providers: [TaskApiService],
});
httpClient = TestBed.get(HttpClient);
taskApiService = TestBed.get(TaskApiService);
httpTestingController = TestBed.get(HttpTestingController);
});
it('should create', () => {
expect(taskApiService).toBeTruthy();
});
it('should create task', () => {
const task = new TaskModel({
name: 'First task',
active: true,
procedureCodeId: '001',
client: '00122',
});
taskApiService.createTask(task)
.subscribe((response) => {
expect(response).toEqual(task);
});
const request = httpTestingController
.expectOne(req => req.method === 'POST' && req.url === `${taskApiService['_url']}/clients/tasks`);
request.flush(task);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment