本文整理匯總了TypeScript中angular.IHttpBackendService.whenGET方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IHttpBackendService.whenGET方法的具體用法?TypeScript IHttpBackendService.whenGET怎麽用?TypeScript IHttpBackendService.whenGET使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular.IHttpBackendService
的用法示例。
在下文中一共展示了IHttpBackendService.whenGET方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: 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);
});
示例2: 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();
});
示例3: beforeEach
beforeEach(angular.mock.inject($injector => {
service = $injector.get("DataService");
$httpBackend = $injector.get("$httpBackend");
caLondonAppConfig = $injector.get("caLondonAppConfig");
caLondonAppConfig.API_URL = "https://myurl.com/";
$httpBackend.whenGET(caLondonAppConfig.API_URL + "api/pages/home").respond([{pageData: "bogus"}]);
}));
示例4: 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([]);
});
示例5: it
it("should not intercept for a 200 response", () => {
$location.path("/page/somepage");
$httpBackend.whenGET("some/url")
.respond([{some: "data"}]);
$http.get("some/url")
.then(() => {
expect($cookies.remove).not.toHaveBeenCalled();
expect($location.path()).toEqual("/page/somepage");
});
$httpBackend.flush();
});
示例6: beforeEach
beforeEach(angular.mock.inject($injector => {
$rootScope = $injector.get("$rootScope");
$httpBackend = $injector.get("$httpBackend");
$httpBackend.whenGET("https://myurl.com/api/pages?contentType").respond(testPageData);
service = $injector.get("PageRouterService");
service.pageTitles = [];
service.pageTitles.push({PageTitle: "Some Title", PageName: "somename"});
service.pageTitles.push({PageTitle: "Some Title 2", PageName: "somename2"});
service.pageTitles.push({PageTitle: "Some Title 3", PageName: "somename3"});
}));
示例7: beforeEach
beforeEach(angular.mock.inject($injector => {
$controller = $injector.get("$controller");
$rootScope = $injector.get("$rootScope");
$window = $injector.get("$window");
$q = $injector.get("$q");
$routeParams = $injector.get("$routeParams");
$templateCache = $injector.get("$templateCache");
$timeout = $injector.get("$timeout");
$httpBackend = $injector.get("$httpBackend");
$scope = $rootScope.$new(true);
caLondonAppConfig = $injector.get("caLondonAppConfig");
pageRouterService = $injector.get("PageRouterService");
caLondonAppConfig.API_URL = "https://myurl.com/";
$routeParams.pageName = "testpage";
$httpBackend.whenGET("https://myurl.com/api/pages?contentType")
.respond([]);
}));
示例8: beforeEach
beforeEach(() => {
$http.whenGET(`${SETTINGS.gateUrl}/reports/reservation/v2`).respond(200, []);
});