本文整理匯總了TypeScript中angular.IHttpBackendService.expectPUT方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IHttpBackendService.expectPUT方法的具體用法?TypeScript IHttpBackendService.expectPUT怎麽用?TypeScript IHttpBackendService.expectPUT使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular.IHttpBackendService
的用法示例。
在下文中一共展示了IHttpBackendService.expectPUT方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should propagate rejection from failed cancel', () => {
let failed = false;
const executionId = 'abc';
const cancelUrl = [ SETTINGS.gateUrl, 'pipelines', executionId, 'cancel' ].join('/');
const application: Application = { name: 'deck', executions: { refresh: () => $q.when(null) } } as any;
$httpBackend.expectPUT(cancelUrl).respond(500, []);
executionService.cancelExecution(application, executionId).then(noop, () => failed = true);
$httpBackend.flush();
expect(failed).toBe(true);
});
示例2: it
it("should PUT data for correct URL", () => {
$httpBackend.expectPUT("https://myurl.com/api/myput").respond({data: "test"});
service.getData({
webservice: "api/myput",
type: "PUT"
}).then(data => {
expect(data).toEqual({data: "test"});
});
$httpBackend.flush();
});
示例3: it
it('should wait until pipeline is RUNNING, then resolve', () => {
let completed = false;
const executionId = 'abc';
const pauseUrl = [SETTINGS.gateUrl, 'pipelines', executionId, 'resume'].join('/');
const singleExecutionUrl = [SETTINGS.gateUrl, 'pipelines', executionId].join('/');
const application: Application = { name: 'deck', executions: { refresh: () => $q.when(null) } } as any;
$httpBackend.expectPUT(pauseUrl).respond(200, []);
$httpBackend.expectGET(singleExecutionUrl).respond(200, { id: executionId, status: 'PAUSED' });
executionService.resumeExecution(application, executionId).then(() => (completed = true));
$httpBackend.flush();
expect(completed).toBe(false);
$httpBackend.expectGET(singleExecutionUrl).respond(200, { id: executionId, status: 'RUNNING' });
timeout.flush();
$httpBackend.flush();
expect(completed).toBe(true);
});
示例4: it
it('should wait until task is canceled, then resolve', () => {
const taskId = 'abc';
const cancelUrl = [API.baseUrl, 'tasks', taskId, 'cancel'].join('/');
const checkUrl = [API.baseUrl, 'tasks', taskId].join('/');
let completed = false;
$httpBackend.expectPUT(cancelUrl).respond(200, []);
$httpBackend.expectGET(checkUrl).respond(200, { id: taskId });
TaskWriter.cancelTask(taskId).then(() => (completed = true));
$httpBackend.flush();
expect(completed).toBe(false);
$httpBackend.expectGET(checkUrl).respond(200, { id: taskId });
timeout.flush();
$httpBackend.flush();
$httpBackend.expectGET(checkUrl).respond(200, { status: 'CANCELED' });
timeout.flush();
$httpBackend.flush();
expect(completed).toBe(true);
});