From 1b2375d6f3449f0e3c4c56344a24e04b2786e9c9 Mon Sep 17 00:00:00 2001 From: Kenji Ishii Date: Fri, 30 Sep 2016 12:02:39 +0900 Subject: [PATCH] Add javascript tests for create label/network/spec This patch adds javascript tests for the following modules. - horizon.dashboard.container-infra.cluster-templates. createClusterTemplateLabelsController - horizon.dashboard.container-infra.cluster-templates. createClusterTemplateNetworkController - horizon.dashboard.container-infra.cluster-templates. createClusterTemplateSpecController Change-Id: I10ca07f2ca7c3ee98281300233f87764bbdad213 --- ...cluster-template.labels.controller.spec.js | 38 ++++++++++++++ ...luster-template.network.controller.spec.js | 38 ++++++++++++++ .../cluster-template.spec.controller.spec.js | 51 +++++++++++++++++++ 3 files changed, 127 insertions(+) create mode 100644 magnum_ui/static/dashboard/container-infra/cluster-templates/create/labels/cluster-template.labels.controller.spec.js create mode 100644 magnum_ui/static/dashboard/container-infra/cluster-templates/create/network/cluster-template.network.controller.spec.js create mode 100644 magnum_ui/static/dashboard/container-infra/cluster-templates/create/spec/cluster-template.spec.controller.spec.js diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/labels/cluster-template.labels.controller.spec.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/labels/cluster-template.labels.controller.spec.js new file mode 100644 index 00000000..52f81c15 --- /dev/null +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/labels/cluster-template.labels.controller.spec.js @@ -0,0 +1,38 @@ +/** + * (c) Copyright 2016 NEC Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + describe('createClusterTemplateLabelsController tests', function() { + var controller; + + beforeEach(module('horizon.dashboard.container-infra.cluster-templates')); + + beforeEach(inject(function ($injector) { + controller = $injector.get('$controller'); + })); + + function createController() { + return controller('createClusterTemplateLabelsController'); + } + + it('should initialise the controller when created', function() { + var ctrl = createController({}); + expect(ctrl).toBeDefined(); + }); + }); +})(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/network/cluster-template.network.controller.spec.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/network/cluster-template.network.controller.spec.js new file mode 100644 index 00000000..6964714a --- /dev/null +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/network/cluster-template.network.controller.spec.js @@ -0,0 +1,38 @@ +/** + * (c) Copyright 2016 NEC Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + describe('createClusterTemplateNetworkController tests', function() { + var controller; + + beforeEach(module('horizon.dashboard.container-infra.cluster-templates')); + + beforeEach(inject(function ($injector) { + controller = $injector.get('$controller'); + })); + + function createController() { + return controller('createClusterTemplateNetworkController'); + } + + it('should initialise the controller when created', function() { + var ctrl = createController({}); + expect(ctrl).toBeDefined(); + }); + }); +})(); diff --git a/magnum_ui/static/dashboard/container-infra/cluster-templates/create/spec/cluster-template.spec.controller.spec.js b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/spec/cluster-template.spec.controller.spec.js new file mode 100644 index 00000000..2524bf1a --- /dev/null +++ b/magnum_ui/static/dashboard/container-infra/cluster-templates/create/spec/cluster-template.spec.controller.spec.js @@ -0,0 +1,51 @@ +/** + * (c) Copyright 2016 NEC Corporation + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ + +(function() { + 'use strict'; + + describe('createClusterTemplateSpecController tests', function() { + var controller, glance, nova; + + function fakePromise() { + return { success: angular.noop }; + } + + beforeEach(module('horizon.dashboard.container-infra.cluster-templates')); + + beforeEach(inject(function ($injector) { + controller = $injector.get('$controller'); + glance = $injector.get('horizon.app.core.openstack-service-api.glance'); + nova = $injector.get('horizon.app.core.openstack-service-api.nova'); + + spyOn(glance, 'getImages').and.callFake(fakePromise); + spyOn(nova, 'getFlavors').and.callFake(fakePromise); + spyOn(nova, 'getKeypairs').and.callFake(fakePromise); + })); + + function createController(scope) { + return controller('createClusterTemplateSpecController', {$scope: scope}); + } + + it('should initialise the controller when created', function() { + var ctrl = createController({}); + expect(ctrl.images).toBeDefined(); + expect(ctrl.nflavors).toBeDefined(); + expect(ctrl.mflavors).toBeDefined(); + expect(ctrl.keypairs).toBeDefined(); + }); + }); +})();