本文整理汇总了TypeScript中angular.IQService类的典型用法代码示例。如果您正苦于以下问题:TypeScript IQService类的具体用法?TypeScript IQService怎么用?TypeScript IQService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IQService类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('Service: SkinService', () => {
let appBuilder: ApplicationModelBuilder, scope: IScope, $q: IQService;
beforeEach(mock.module(APPLICATION_MODEL_BUILDER));
beforeEach(
mock.inject(($rootScope: IRootScopeService, _$q_: IQService, applicationModelBuilder: ApplicationModelBuilder) => {
appBuilder = applicationModelBuilder;
scope = $rootScope.$new();
$q = _$q_;
}),
);
describe('instance skin disambiguation', () => {
beforeEach(() => {
spyOn(SkinService, 'getAccounts').and.returnValue(
$q.resolve([
{ name: 'v1-k8s-account', cloudProvider: 'kubernetes', skin: 'v1' },
{ name: 'v2-k8s-account', cloudProvider: 'kubernetes', skin: 'v2' },
{ name: 'appengine-account', cloudProvider: 'appengine', skin: 'v1' },
{ name: 'gce-account', cloudProvider: 'gce' },
]),
);
});
it('uses available accounts to determine skin if possible', () => {
const app = appBuilder.createStandaloneApplication('myApp');
SkinService.getInstanceSkin('appengine', 'my-instance-id', app).then(skin => {
expect(skin).toEqual('v1');
});
SkinService.getInstanceSkin('gce', 'my-instance-id', app).then(skin => {
expect(skin).toEqual(null);
});
scope.$digest();
});
it('scrapes application server groups to determine skin if possible', () => {
const app = appBuilder.createApplication('myApp', [
{
key: 'serverGroups',
data: [
{
name: 'myServerGroup',
account: 'v2-k8s-account',
cloudProvider: 'kubernetes',
instances: [{ id: 'my-instance-id' }],
serverGroups: [],
},
],
},
{
key: 'loadBalancers',
data: [],
},
]);
SkinService.getInstanceSkin('kubernetes', 'my-instance-id', app).then(skin => {
expect(skin).toEqual('v2');
});
scope.$digest();
});
it('scrapes application load balancers to determine skin if possible', () => {
const app = appBuilder.createApplication('myApp', [
{
key: 'loadBalancers',
data: [
{
name: 'myLoadBalancer',
account: 'v2-k8s-account',
cloudProvider: 'kubernetes',
instances: [{ id: 'my-instance-id' }],
},
],
},
{
key: 'serverGroups',
data: [],
},
]);
SkinService.getInstanceSkin('kubernetes', 'my-instance-id', app).then(skin => {
expect(skin).toEqual('v2');
});
scope.$digest();
});
it("scrapes application load balancers' server groups to determine skin if possible", () => {
const app = appBuilder.createApplication('myApp', [
{
key: 'loadBalancers',
data: [
{
name: 'myLoadBalancer',
account: 'v2-k8s-account',
cloudProvider: 'kubernetes',
//.........这里部分代码省略.........
示例2: describe
describe('Travis Stage Controller', () => {
let $scope: IScope, $q: IQService, $ctrl: IControllerService;
beforeEach(mock.module(TRAVIS_STAGE, require('angular-ui-bootstrap')));
beforeEach(
mock.inject(($controller: IControllerService, $rootScope: IRootScopeService, _$q_: IQService) => {
$ctrl = $controller;
$scope = $rootScope.$new();
$q = _$q_;
}),
);
const initialize = (stage: any): TravisStage => {
return $ctrl(TravisStage, {
stage,
$scope,
});
};
describe('updateJobsList', () => {
beforeEach(() => {
spyOn(IgorService, 'listMasters').and.returnValue($q.when([]));
});
it('does nothing if master is parameterized', () => {
spyOn(IgorService, 'listJobsForMaster');
const stage = {
master: '${parameter.master}',
};
const controller = initialize(stage);
$scope.$digest();
expect(controller.jobs).toBeUndefined();
expect(controller.viewState.jobsLoaded).toBe(true);
expect((IgorService.listJobsForMaster as Spy).calls.count()).toBe(0);
});
it('does nothing if job is parameterized', () => {
spyOn(IgorService, 'listJobsForMaster');
const stage = {
master: 'not-parameterized',
job: '${parameter.job}',
};
const controller = initialize(stage);
$scope.$digest();
expect(controller.jobs).toBeUndefined();
expect(controller.viewState.jobsLoaded).toBe(true);
expect((IgorService.listJobsForMaster as Spy).calls.count()).toBe(0);
});
it('gets jobs from igor and adds them to scope', () => {
spyOn(IgorService, 'listJobsForMaster').and.returnValue($q.when(['a', 'b']));
const stage = {
master: 'not-parameterized',
};
const controller = initialize(stage);
$scope.$digest();
expect(controller.jobs).toEqual(['a', 'b']);
expect(controller.viewState.jobsLoaded).toBe(true);
});
it('clears job if no longer present when retrieving from igor', () => {
spyOn(IgorService, 'listJobsForMaster').and.returnValue($q.when(['a', 'b']));
spyOn(IgorService, 'getJobConfig').and.returnValue($q.when(null));
const stage = {
master: 'not-parameterized',
job: 'c',
};
const controller = initialize(stage);
$scope.$digest();
expect(controller.jobs).toEqual(['a', 'b']);
expect(controller.viewState.jobsLoaded).toBe(true);
expect(stage.job).toBe('');
});
});
describe('updateJobConfig', () => {
beforeEach(() => {
spyOn(IgorService, 'listMasters').and.returnValue($q.when([]));
});
it('does nothing if master is parameterized', () => {
spyOn(IgorService, 'listJobsForMaster');
spyOn(IgorService, 'getJobConfig');
const stage = {
master: '${parameter.master}',
};
const controller = initialize(stage);
$scope.$digest();
expect(controller.jobs).toBeUndefined();
expect(controller.viewState.jobsLoaded).toBe(true);
expect((IgorService.listJobsForMaster as Spy).calls.count()).toBe(0);
expect((IgorService.getJobConfig as Spy).calls.count()).toBe(0);
});
it('does nothing if job is parameterized', () => {
spyOn(IgorService, 'listJobsForMaster');
spyOn(IgorService, 'getJobConfig');
const stage = {
master: 'not-parameterized',
//.........这里部分代码省略.........
示例3: describe
describe("CaStructuredDataCtrl", () => {
let ctrl: CaStructuredDataCtrl, session: SessionService, alertModalService: AlertModalService,
caPageHeaderInfoService: CaStructuredDataService, dataService: DataService;
let $controller: IControllerService, $rootScope: IRootScopeService, $q: IQService,
$sce: ISCEService, $filter: IFilterService;
const fakeLdJson: Array<IStructuredData> = [{
"@context": "http://schema.org",
"@type": "Event",
"name": "Bogus structured data",
"location" : {
"@type" : "Place",
"name" : "Studio 54"
}
}];
beforeEach(() => angular.mock.module(CORE_MODULE));
beforeEach(angular.mock.inject($injector => {
$controller = $injector.get("$controller");
$rootScope = $injector.get("$rootScope");
$sce = $injector.get("$sce");
$q = $injector.get("$q");
$filter = $injector.get("$filter");
dataService = $injector.get("DataService");
spyOn(dataService, "getData").and.callFake(() => {
const deferred: IDeferred<Array<IStructuredData>> = $q.defer();
deferred.resolve(fakeLdJson);
return deferred.promise;
});
session = $injector.get("SessionService");
alertModalService = $injector.get("AlertModalService");
caPageHeaderInfoService = $injector.get("CaStructuredDataService");
$sce.trustAsHtml = data => `trusted ${data}`;
ctrl = $controller("CaStructuredDataCtrl", {});
}));
it("should instantiate and load data when data ready event is emitted", () => {
caPageHeaderInfoService.structuredData = [];
expect(ctrl).toBeDefined();
expect(ctrl.structuredData).toEqual([]);
$rootScope.$digest();
expect(ctrl.structuredData).toEqual(fakeLdJson);
});
describe("#getLdJson", () => {
it("should return trusted version of structured ld+json data", () => {
ctrl.structuredData = [{something: "some data"}];
const actual: Array<IStructuredData> = ctrl.getLdJson();
expect(actual).toEqual("trusted [\n {\n \"something\": \"some data\"\n }\n]");
});
});
});
示例4: normalizeServerGroup
public normalizeServerGroup(serverGroup: any): IPromise<any> {
return this.$q.when(serverGroup);
}
示例5:
const application: Application = { name: 'deck', executions: { refresh: () => $q.when(null) } } as any;
示例6: spyOn
spyOn(ctrl, "getForgottenDialogResult").and.callFake(() => {
const deferred: IDeferred<any> = $q.defer();
deferred.resolve("bogus@user.name");
return deferred.promise;
});
示例7: beforeEach
beforeEach(() => {
spyOn(IgorService, 'listMasters').and.returnValue($q.when([]));
});