本文整理匯總了TypeScript中angular.IScope.%24digest方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript IScope.%24digest方法的具體用法?TypeScript IScope.%24digest怎麽用?TypeScript IScope.%24digest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類angular.IScope
的用法示例。
在下文中一共展示了IScope.%24digest方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('gets all accounts, then adds wildcard and regions per account to vm', () => {
const accounts: any = [
{ name: 'prod', regions: [{ name: 'us-east-1' }, { name: 'us-west-1' }] },
{ name: 'test', regions: [{ name: 'us-west-2' }, { name: 'eu-west-1' }] },
];
spyOn(AccountService, 'listAllAccounts').and.returnValue($q.when(accounts));
initializeController(null);
$ctrl.application = ApplicationModelBuilder.createApplicationForTests('app', {
key: 'serverGroups',
loader: () => $q.resolve([]),
onLoad: (_app, data) => $q.resolve(data),
});
$ctrl.application.serverGroups.refresh();
$scope.$digest();
$ctrl.config = new ChaosMonkeyConfig($ctrl.application.attributes.chaosMonkey || {});
$ctrl.$onInit();
$scope.$digest();
expect($ctrl.accounts).toEqual([accounts[0], accounts[1]]);
expect($ctrl.regionsByAccount).toEqual({
prod: ['*', 'us-east-1', 'us-west-1'],
test: ['*', 'us-west-2', 'eu-west-1'],
});
});
示例2: it
it('attempts to reload firewalls if some are not found on initialization, but does not set dirty flag', function() {
spyOn(AccountService, 'getCredentialsKeyedByAccount').and.returnValue($q.when([]));
const getAllSecurityGroupsSpy = spyOn(securityGroupReader, 'getAllSecurityGroups').and.returnValue($q.when([]));
spyOn(loadBalancerReader, 'listLoadBalancers').and.returnValue($q.when(this.allLoadBalancers));
spyOn(SubnetReader, 'listSubnets').and.returnValue($q.when([]));
spyOn(AccountService, 'getPreferredZonesByAccount').and.returnValue($q.when([]));
spyOn(KeyPairsReader, 'listKeyPairs').and.returnValue($q.when([]));
spyOn(awsInstanceTypeService, 'getAllTypesByRegion').and.returnValue($q.when([]));
const refreshCacheSpy = spyOn(cacheInitializer, 'refreshCache').and.returnValue($q.when(null));
const command = {
credentials: 'test',
region: 'us-east-1',
securityGroups: ['sg-1'],
vpcId: null,
viewState: {
disableImageSelection: true,
dirty: {},
},
} as any;
service.configureCommand(
ApplicationModelBuilder.createApplicationForTests('name', { key: 'loadBalancers', lazy: true }),
command,
);
$scope.$digest();
$scope.$digest();
expect(cacheInitializer.refreshCache).toHaveBeenCalledWith('securityGroups');
expect(refreshCacheSpy.calls.count()).toBe(1);
expect(getAllSecurityGroupsSpy.calls.count()).toBe(2);
});
示例3: it
it ('attempts to reload security groups if some are not found on initialization, but does not set dirty flag', function () {
spyOn(accountService, 'getCredentialsKeyedByAccount').and.returnValue($q.when([]));
const getAllSecurityGroupsSpy = spyOn(securityGroupReader, 'getAllSecurityGroups').and.returnValue($q.when([]));
spyOn(loadBalancerReader, 'listLoadBalancers').and.returnValue($q.when(this.allLoadBalancers));
spyOn(subnetReader, 'listSubnets').and.returnValue($q.when([]));
spyOn(accountService, 'getPreferredZonesByAccount').and.returnValue($q.when([]));
spyOn(keyPairsReader, 'listKeyPairs').and.returnValue($q.when([]));
spyOn(awsInstanceTypeService, 'getAllTypesByRegion').and.returnValue($q.when([]));
const refreshCacheSpy = spyOn(cacheInitializer, 'refreshCache').and.returnValue($q.when(null));
const command = {
credentials: 'test',
region: 'us-east-1',
securityGroups: [ 'sg-1' ],
vpcId: null,
viewState: {
disableImageSelection: true,
dirty: {},
}
} as IAmazonServerGroupCommand;
service.configureCommand({} as Application, command);
$scope.$digest();
$scope.$digest();
expect(cacheInitializer.refreshCache).toHaveBeenCalledWith('securityGroups');
expect(refreshCacheSpy.calls.count()).toBe(1);
expect(getAllSecurityGroupsSpy.calls.count()).toBe(2);
expect(command.dirty).toBeUndefined();
});
示例4: it
it("should post draft cart contents for existing order and display success message", () => {
spyOn(literatureService, "postDraftLitOrder").and.callFake(() => {
const deferred: IDeferred<any> = $q.defer();
deferred.resolve({OrderNum: 4});
return deferred.promise;
});
ctrl.litCart.orderNum = 4;
ctrl.saveDraft();
$scope.$digest();
expect(literatureService.postDraftLitOrder).toHaveBeenCalledWith([{
ItemTypeDescription: "Keyrings",
ItemName: "30 days",
LitItemsID: 1,
SalePriceEach: 3,
Multiple: 1,
Quantity: 2
},
{
ItemTypeDescription: "Something else",
ItemName: "30 days",
LitItemsID: 4,
SalePriceEach: 6,
Multiple: 1,
Quantity: 5
}], "litordertestcom", "litorder@test.com", "litadmintestcom", 4);
expect(alertModalService.show).toHaveBeenCalledWith({
style: "info",
title: "Information",
message: "Order 4 has been saved as a Draft for later. This order has not been sent to the Literature Committee for processing. To do this, submit the order."
});
expect(ctrl.activate).toHaveBeenCalled();
});
示例5: it
it("scrapes application load balancers' server groups to determine skin if possible", () => {
const app = ApplicationModelBuilder.createApplicationForTests(
'myApp',
{
key: 'loadBalancers',
loader: () =>
$q.resolve([
{
name: 'myLoadBalancer',
account: 'v2-k8s-account',
cloudProvider: 'kubernetes',
instances: [],
serverGroups: [
{
isDisabled: true,
instances: [{ id: 'my-instance-id' }],
},
],
},
]),
onLoad: (_app, data) => $q.resolve(data),
},
{
key: 'serverGroups',
},
);
SkinService.getInstanceSkin('kubernetes', 'my-instance-id', app).then(skin => {
expect(skin).toEqual('v2');
});
scope.$digest();
});
示例6: beforeEach
beforeEach(() => {
alarm = makeAlarm('AWS/EC2', 'CPUUtilization', 'GreaterThanThreshold', [
{ name: 'AutoScalingGroupName', value: 'asg-v000' },
]);
serverGroup = makeServerGroup('asg-v000');
spyOn(CloudMetricsReader, 'listMetrics').and.returnValue(
$q.when([
{
namespace: 'AWS/EC2',
name: 'CPUUtilization',
dimensions: [{ name: 'AutoScalingGroupName', value: 'asg-v000' }],
},
{
namespace: 'AWS/EC2',
name: 'NetworkIn',
dimensions: [{ name: 'AutoScalingGroupName', value: 'asg-v000' }, { name: 'sr', value: '71' }],
},
{
namespace: 'AWS/EBS',
name: 'somethingElse',
dimensions: [],
},
]),
);
initialize();
$scope.$digest();
});
示例7: it
it("should open the Upload dialog box", () => {
spyOn(uploadModalService, "show").and.callFake(() => {
const deferred: IDeferred<IFTPFile> = $q.defer();
deferred.resolve({
Filename: "new-file.png",
CreatedDate: moment("2019-09-16T13:08:00"),
Size: 111,
Folder: "Downloads",
HtmlCode: "<img src='something' />"
});
return deferred.promise;
});
ctrl = getController();
ctrl.upload();
$scope.$digest();
expect(uploadModalService.show).toHaveBeenCalledWith(FileUploaderCtrl.ftpFolders);
expect(ctrl.files[21]).toEqual({
Filename: "new-file.png",
CreatedDate: moment("2019-09-16T13:08:00"),
Size: 111,
Folder: "Downloads",
HtmlCode: "<img src='something' />"
});
});
示例8: it
it("should show error message when response is bad", () => {
spyOn(pageEditorService, "postPage").and.callFake(() => {
const deferred: IDeferred<any> = $q.defer();
deferred.reject();
return deferred.promise;
});
ctrl.editor = TestPageWithContent;
ctrl.editor.PageContent = "<div>new content</div>";
ctrl.submit();
expect(pageEditorService.postPage).toHaveBeenCalledWith("read-andallo", 3, {
PageTitle: "...And All Other Mind Altering Substances",
PageContent: "<div>new content</div>",
Status: "ACTIVE",
ContentType: "R",
ImageFilename: "PAMPHLETS_All_Other"
});
$scope.$digest();
expect(alertModalService.show).toHaveBeenCalledWith({
style: "danger",
title: "Failed to save changes",
message: "Could not save changes due to an unknown error. Please try again later."
});
expect($location.path()).toEqual("/page/pageeditform");
});
示例9: it
it('should put default security groups in the front of the available list', () => {
AWSProviderSettings.defaultSecurityGroups = ['sg-a'];
AWSProviderSettings.defaults.subnetType = 'external';
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'},
{name: 'sg-a', id: '5', vpcId: 'vpc-1'}]
}
}
};
spyOn(securityGroupReader, 'getAllSecurityGroups').and.returnValue($q.when(availableSecurityGroups));
spyOn(accountService, 'listAccounts').and.returnValue($q.when([{name: 'test'}]));
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', purpose: 'external'}
]));
spyOn(amazonCertificateReader, 'listCertificates').and.returnValue($q.when([]));
initialize();
$scope.$digest();
expect(controller.availableSecurityGroups.map(g => g.name)).toEqual(['sg-a', 'a', 'b', 'c', 'd']);
});
示例10: beforeEach
beforeEach(angular.mock.inject($injector => {
$controller = $injector.get("$controller");
$rootScope = $injector.get("$rootScope");
$compile = $injector.get("$compile");
$q = $injector.get("$q");
$scope = $rootScope.$new(true);
downloadsService = $injector.get("DownloadsService");
spyOn(downloadsService, "getDownloads").and.callFake(() => {
const deferred: IDeferred<Array<IDownload>> = $q.defer();
deferred.resolve(TestDownloads);
return deferred.promise;
});
spyOn(downloadsService, "getCategories").and.callFake(() => {
const deferred: IDeferred<Array<ICategory>> = $q.defer();
deferred.resolve(TestCategories);
return deferred.promise;
});
component = angular.element(`<downloads></downloads>`);
$compile(component)($scope);
ctrl = component.controller("downloads");
$scope.$digest();
}));