Last active
May 4, 2020 11:04
-
-
Save AntonGorelov/69dcdc830153d4ec3ebf9b8fbb750433 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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