本文整理匯總了TypeScript中angular.IHttpBackendService.flush方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IHttpBackendService.flush方法的具體用法?TypeScript IHttpBackendService.flush怎麽用?TypeScript IHttpBackendService.flush使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular.IHttpBackendService
的用法示例。
在下文中一共展示了IHttpBackendService.flush方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('rejects if execution retrieval fails', () => {
const executionId = 'abc';
const url = [SETTINGS.gateUrl, 'pipelines', executionId].join('/');
let succeeded = false;
let failed = false;
$httpBackend.expectGET(url).respond(200, { thingToMatch: false });
executionService.waitUntilExecutionMatches(executionId, (execution) => (execution as any).thingToMatch)
.then(() => succeeded = true, () => failed = true);
expect(succeeded).toBe(false);
expect(failed).toBe(false);
$httpBackend.flush();
// no match, retrying
expect(succeeded).toBe(false);
expect(failed).toBe(false);
$httpBackend.expectGET(url).respond(500, '');
timeout.flush();
$httpBackend.flush();
expect(succeeded).toBe(false);
expect(failed).toBe(true);
});
示例2: 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);
});
示例3: it
it('returns an empty list instead of failing if tags cannot be loaded', () => {
$http.whenGET(`${SETTINGS.gateUrl}/tags?entityId=a,b&entityType=servergroups&maxResults=2`).respond(400, 'bad request');
let result: any = null;
service.getAllEntityTags('serverGroups', ['a', 'b']).then(r => result = r);
$http.flush();
$timeout.flush();
$http.flush();
expect(result).toEqual([]);
});
示例4: it
it('adds label to subnet, including (deprecated) if deprecated field is true', function() {
$http
.whenGET(API.baseUrl + '/subnets')
.respond(200, [
{ purpose: 'internal', deprecated: true },
{ purpose: 'external', deprecated: false },
{ purpose: 'internal' },
]);
let result: ISubnet[] = null;
SubnetReader.listSubnets().then((subnets: ISubnet[]) => {
result = subnets;
});
$http.flush();
$scope.$digest();
expect(result[0].label).toBe('internal (deprecated)');
expect(result[0].deprecated).toBe(true);
expect(result[1].label).toBe('external');
expect(result[1].deprecated).toBe(false);
expect(result[2].label).toBe('internal');
expect(result[2].deprecated).toBe(false);
});
示例5: it
it('should return the build config', () => {
const buildId = 'bc_bid';
$http.expectGET(`${CI_BUILD_URL}/${buildId}/config`).respond(200, {});
ciBuildReader.getBuildConfig(buildId);
$http.flush();
});
示例6: it
it('should return a non-empty array when configured to do so and invoked', () => {
const services: IPagerDutyService[] = [
{
name: 'one',
integration_key: 'one_key',
id: '1',
policy: 'ABCDEF',
lastIncidentTimestamp: '1970',
status: 'active',
},
{
name: '2',
integration_key: 'two_key',
id: '2',
policy: 'ABCDEG',
lastIncidentTimestamp: '1970',
status: 'active',
},
];
$http.whenGET(`${API.baseUrl}/pagerDuty/services`).respond(200, services);
let executed = false;
PagerDutyReader.listServices().subscribe((pagerDutyServices: IPagerDutyService[]) => {
expect(pagerDutyServices).toBeDefined();
expect(pagerDutyServices.length).toBe(2);
executed = true; // can't use done() function b/c $digest is already in progress
});
$http.flush();
expect(executed).toBeTruthy();
});
示例7: it
it('returns null when gist fetch fails', () => {
let result: IWhatsNewContents = { contents: 'fail', lastUpdated: 'never' };
$http.expectGET(url).respond(404, {});
WhatsNewReader.getWhatsNewContents().then(data => (result = data));
$http.flush();
expect(result).toBeNull();
});