本文整理汇总了TypeScript中angular.IQService.when方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IQService.when方法的具体用法?TypeScript IQService.when怎么用?TypeScript IQService.when使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular.IQService
的用法示例。
在下文中一共展示了IQService.when方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should put existing security groups in the front of the available list', () => {
const availableSecurityGroups = {
test: {
aws: {
'us-east-1': [
{name: 'a', id: '1', vpcId: 'vpc-1'},
{name: 'b', id: '2', vpcId: 'vpc-1'},
{name: 'c', id: '3', vpcId: 'vpc-1'},
{name: 'd', id: '4', vpcId: 'vpc-1'}]
}
}
};
const existingLoadBalancer = {
name: 'elb-1',
vpcId: 'vpc-1',
credentials: 'test',
region: 'us-east-1',
securityGroups: ['4'],
listeners: [],
} as IAmazonClassicLoadBalancer;
spyOn(securityGroupReader, 'getAllSecurityGroups').and.returnValue($q.when(availableSecurityGroups));
spyOn(accountService, 'getAccountDetails').and.returnValue($q.when([{name: 'test'}]));
spyOn(subnetReader, 'listSubnets').and.returnValue($q.when([{account: 'test', region: 'us-east-1', vpcId: 'vpc-1'}]));
spyOn(amazonCertificateReader, 'listCertificates').and.returnValue($q.when([]));
initialize(existingLoadBalancer);
$scope.$digest();
expect(controller.availableSecurityGroups.map(g => g.name)).toEqual(['d', 'a', 'b', 'c']);
});
示例2: uniq
return this.accountService.listProviders(application).then((providers) => {
let provider;
let reducedProviders: string[] = [];
if (feature) {
reducedProviders = providers.filter((p) => this.cloudProviderRegistry.hasValue(p, feature));
}
// reduce the providers to the smallest, unique collection taking into consideration the useProvider values
reducedProviders = uniq(reducedProviders.map((providerName) => {
const providerFeature = this.cloudProviderRegistry.getProvider(providerName)[feature] || {};
return providerFeature.useProvider || providerName;
}));
if (reducedProviders.length > 1) {
provider = this.$uibModal.open({
templateUrl: require('./providerSelection.html'),
controller: 'ProviderSelectCtrl as ctrl',
resolve: {
providerOptions: () => reducedProviders
}
}).result;
} else if (reducedProviders.length === 1) {
provider = this.$q.when(reducedProviders[0]);
} else {
provider = this.$q.when(SETTINGS.defaultProvider || 'aws');
}
return provider;
});
示例3: filterFn
return this.accountService.applicationAccounts(application).then((accounts: IAccountDetails[]) => {
let reducedAccounts: IAccountDetails[] = [];
if (feature) {
reducedAccounts = accounts.filter(a => this.cloudProviderRegistry.hasValue(a.cloudProvider, feature));
}
if (filterFn) {
reducedAccounts = reducedAccounts.filter((acc: IAccountDetails) => {
return filterFn(application, acc, this.cloudProviderRegistry.getProvider(acc.cloudProvider, acc.providerVersion));
});
}
// reduce the accounts to the smallest, unique collection taking into consideration the useProvider values
const reducedProviders = uniq(reducedAccounts.map(a => {
const providerFeature = this.cloudProviderRegistry.getProvider(a.cloudProvider)[feature] || {};
return providerFeature.useProvider || a.cloudProvider;
}));
let provider;
if (reducedProviders.length > 1) {
provider = this.$uibModal.open({
templateUrl: require('./providerSelection.html'),
controller: 'ProviderSelectCtrl as ctrl',
resolve: {
providerOptions: () => reducedProviders
}
}).result;
} else if (reducedProviders.length === 1) {
provider = this.$q.when(reducedProviders[0]);
} else {
provider = this.$q.when(SETTINGS.defaultProvider || 'aws');
}
return provider;
});
示例4: it
it('gets job config and adds parameters to scope, setting defaults if present and not overridden', () => {
const params: IParameterDefinitionList[] = [
{ name: 'overridden', defaultValue: 'z' },
{ name: 'notSet', defaultValue: 'a' },
{ name: 'noDefault', defaultValue: null },
];
const jobConfig = {
parameterDefinitionList: params,
} as IJobConfig;
spyOn(IgorService, 'listJobsForMaster').and.returnValue($q.when(['a', 'b']));
spyOn(IgorService, 'getJobConfig').and.returnValue($q.when(jobConfig));
const stage = {
master: 'not-parameterized',
job: 'a',
parameters: {
overridden: 'f',
},
};
const controller = initialize(stage);
$scope.$digest();
expect(controller.jobs).toEqual(['a', 'b']);
expect(controller.viewState.jobsLoaded).toBe(true);
expect(controller.stage.job).toBe('a');
expect(controller.jobParams).toBe(params);
expect(controller.useDefaultParameters.overridden).toBeUndefined();
expect(controller.useDefaultParameters.notSet).toBe(true);
expect(controller.useDefaultParameters.noDefault).toBeUndefined();
});
示例5: beforeEach
beforeEach(() => {
initialized = false;
spyOn(AccountService, 'listAllAccounts').and.returnValue($q.when(keys.account));
spyOn(securityGroupReader, 'getAllSecurityGroups').and.returnValue($q.when(keys.sg));
spyOn(ApplicationReader, 'listApplications').and.returnValue($q.when(keys.app));
spyOn(IgorService, 'listMasters').and.returnValue($q.when(keys.bm));
spyOn(AccountService, 'listProviders').and.returnValue($q.when([]));
});
示例6: it
it('gets list of jobs when initialized with a trigger with a master and sets loading states', () => {
const jobs = ['some_job', 'some_other_job'],
trigger = { master: 'travis', job: 'some_job' } as IBuildTrigger;
spyOn(IgorService, 'listJobsForMaster').and.returnValue($q.when(jobs));
spyOn(IgorService, 'listMasters').and.returnValue($q.when(['travis']));
const controller = initializeController(trigger);
expect(controller.viewState.jobsLoaded).toBe(false);
expect(controller.viewState.mastersLoaded).toBe(false);
$scope.$digest();
expect(controller.jobs).toBe(jobs);
expect(controller.masters).toEqual(['travis']);
expect(controller.viewState.jobsLoaded).toBe(true);
expect(controller.viewState.mastersLoaded).toBe(true);
});
示例7: it
it('gets list of jobs when initialized with a wercker master and sets loading states', () => {
const jobs = ['type/org/app/p1', 'type/org/app/p2'],
trigger = { master: 'wercker', job: 'type/org/app/some_job' } as IWerckerTrigger;
spyOn(IgorService, 'listJobsForMaster').and.returnValue($q.when(jobs));
spyOn(IgorService, 'listMasters').and.returnValue($q.when(['wercker']));
const controller = initializeController(trigger);
expect(controller.viewState.appsLoaded).toBe(false);
expect(controller.viewState.mastersLoaded).toBe(false);
$scope.$digest();
expect(controller.jobs).toBe(jobs);
expect(controller.masters).toEqual(['wercker']);
expect(controller.viewState.appsLoaded).toBe(true);
expect(controller.viewState.mastersLoaded).toBe(true);
});
示例8: keys
.then((backingData: Partial<IEcsServerGroupCommandBackingData>) => {
let loadBalancerReloader = this.$q.when();
backingData.accounts = keys(backingData.credentialsKeyedByAccount);
backingData.filtered = {} as IEcsServerGroupCommandBackingDataFiltered;
cmd.backingData = backingData as IEcsServerGroupCommandBackingData;
this.configureVpcId(cmd);
this.configureAvailableIamRoles(cmd);
this.configureAvailableSubnetTypes(cmd);
this.configureAvailableSecurityGroups(cmd);
this.configureAvailableMetricAlarms(cmd);
this.configureAvailableEcsClusters(cmd);
if (cmd.loadBalancers && cmd.loadBalancers.length) {
// verify all load balancers are accounted for; otherwise, try refreshing load balancers cache
const loadBalancerNames = this.getLoadBalancerNames(cmd);
if (intersection(loadBalancerNames, cmd.loadBalancers).length < cmd.loadBalancers.length) {
loadBalancerReloader = this.refreshLoadBalancers(cmd, true);
}
}
return this.$q.all([loadBalancerReloader]).then(() => {
this.applyOverrides('afterConfiguration', cmd);
this.attachEventHandlers(cmd);
});
});