本文整理匯總了TypeScript中angular.IHttpBackendService.expectDELETE方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IHttpBackendService.expectDELETE方法的具體用法?TypeScript IHttpBackendService.expectDELETE怎麽用?TypeScript IHttpBackendService.expectDELETE使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular.IHttpBackendService
的用法示例。
在下文中一共展示了IHttpBackendService.expectDELETE方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should wait until task is gone, then resolve', () => {
const taskId = 'abc';
const deleteUrl = [API.baseUrl, 'tasks', taskId].join('/');
const checkUrl = [API.baseUrl, 'tasks', taskId].join('/');
let completed = false;
$httpBackend.expectDELETE(deleteUrl).respond(200, []);
taskWriter.deleteTask(taskId).then(() => completed = true);
// first check: task is still present
$httpBackend.expectGET(checkUrl).respond(200, [{id: taskId}]);
$httpBackend.flush();
expect(completed).toBe(false);
// second check: task retrieval returns some error, try again
$httpBackend.expectGET(checkUrl).respond(500, null);
timeout.flush();
$httpBackend.flush();
expect(completed).toBe(false);
// third check: task is not present, should complete
$httpBackend.expectGET(checkUrl).respond(404, null);
timeout.flush();
$httpBackend.flush();
expect(completed).toBe(true);
});
示例2: it
it('should propagate rejection from failed delete', () => {
let failed = false;
const executionId = 'abc';
const deleteUrl = [ SETTINGS.gateUrl, 'pipelines', executionId ].join('/');
const application: Application = { name: 'deck', executions: { refresh: () => $q.when(null) } } as any;
$httpBackend.expectDELETE(deleteUrl).respond(500, []);
executionService.deleteExecution(application, executionId).then(noop, () => failed = true);
$httpBackend.flush();
expect(failed).toBe(true);
});