From 2435f1b3f987854dc94e9359bb69adb678b45286 Mon Sep 17 00:00:00 2001 From: Shaoquan Chen Date: Fri, 14 Aug 2015 17:05:51 -0700 Subject: [PATCH] Moving inline html code out of action-list.spec.js Currently there are some html code for test hard-coded inside of spec.js file. It would be much better to move them out to separate html file for better readability, cleaner spec code. This will also enable the sharing html mock code between specs. This patch moves inline html code out of action-list.spec.js. Change-Id: Id05fbf3948fad3926cc3ecc09e0c95acc84ce41e Partial-Bug: #1485134 --- ...tion-list.single-button-dropdown.mock.html | 11 +++++ .../widgets/action-list/action-list.spec.js | 47 ++++++------------- ...ction-list.split-botton-dropdown.mock.html | 13 +++++ .../action-list/button-group.mock.html | 5 ++ 4 files changed, 43 insertions(+), 33 deletions(-) create mode 100644 horizon/static/framework/widgets/action-list/action-list.single-button-dropdown.mock.html create mode 100644 horizon/static/framework/widgets/action-list/action-list.split-botton-dropdown.mock.html create mode 100644 horizon/static/framework/widgets/action-list/button-group.mock.html diff --git a/horizon/static/framework/widgets/action-list/action-list.single-button-dropdown.mock.html b/horizon/static/framework/widgets/action-list/action-list.single-button-dropdown.mock.html new file mode 100644 index 0000000000..9fbc4dfa24 --- /dev/null +++ b/horizon/static/framework/widgets/action-list/action-list.single-button-dropdown.mock.html @@ -0,0 +1,11 @@ + + Actions + + + Edit + + + Delete + + + diff --git a/horizon/static/framework/widgets/action-list/action-list.spec.js b/horizon/static/framework/widgets/action-list/action-list.spec.js index 6204ea51de..6d0a35d0ae 100644 --- a/horizon/static/framework/widgets/action-list/action-list.spec.js +++ b/horizon/static/framework/widgets/action-list/action-list.spec.js @@ -24,14 +24,16 @@ describe('action-list directive', function () { beforeEach(module('templates')); - beforeEach(module('horizon.framework.widgets')); - beforeEach(module('horizon.framework.widgets.action-list')); + beforeEach(module('horizon.framework')); describe('single button dropdown', function () { var $scope, $element; beforeEach(inject(function ($injector) { var $compile = $injector.get('$compile'); + var $templateCache = $injector.get('$templateCache'); + var basePath = $injector.get('horizon.framework.widgets.basePath'); + $scope = $injector.get('$rootScope').$new(); $scope.testList = []; @@ -41,18 +43,8 @@ $scope.testList.push(item); }; - var markup = - '' + - ' Actions' + - ' ' + - ' ' + - ' Edit' + - ' ' + - ' ' + - ' Delete' + - ' ' + - ' ' + - ''; + var markup = $templateCache + .get(basePath + 'action-list/action-list.single-button-dropdown.mock.html'); $element = angular.element(markup); $compile($element)($scope); @@ -85,6 +77,8 @@ beforeEach(inject(function ($injector) { var $compile = $injector.get('$compile'); + var $templateCache = $injector.get('$templateCache'); + var basePath = $injector.get('horizon.framework.widgets.basePath'); $scope = $injector.get('$rootScope').$new(); $scope.testList = []; @@ -94,20 +88,8 @@ $scope.testList.push(item); }; - var markup = - '' + - ' ' + - ' View' + - ' ' + - ' ' + - ' ' + - ' Edit' + - ' ' + - ' ' + - ' Delete' + - ' ' + - ' ' + - ''; + var markup = $templateCache + .get(basePath + 'action-list/action-list.split-botton-dropdown.mock.html'); $element = angular.element(markup); $compile($element)($scope); @@ -151,6 +133,8 @@ beforeEach(inject(function ($injector) { var $compile = $injector.get('$compile'); + var $templateCache = $injector.get('$templateCache'); + var basePath = $injector.get('horizon.framework.widgets.basePath'); $scope = $injector.get('$rootScope').$new(); $scope.testList = []; @@ -160,11 +144,8 @@ $scope.testList.push(item); }; - var markup = '' + - ' View' + - ' Edit' + - ' Delete' + - ''; + var markup = $templateCache + .get(basePath + 'action-list/button-group.mock.html'); $element = angular.element(markup); $compile($element)($scope); diff --git a/horizon/static/framework/widgets/action-list/action-list.split-botton-dropdown.mock.html b/horizon/static/framework/widgets/action-list/action-list.split-botton-dropdown.mock.html new file mode 100644 index 0000000000..522a75646e --- /dev/null +++ b/horizon/static/framework/widgets/action-list/action-list.split-botton-dropdown.mock.html @@ -0,0 +1,13 @@ + + + View + + + + Edit + + + Delete + + + diff --git a/horizon/static/framework/widgets/action-list/button-group.mock.html b/horizon/static/framework/widgets/action-list/button-group.mock.html new file mode 100644 index 0000000000..b803f0b917 --- /dev/null +++ b/horizon/static/framework/widgets/action-list/button-group.mock.html @@ -0,0 +1,5 @@ + + View + Edit + Delete +