summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarliana Lara <mlara@redhat.com>2017-09-26 20:20:30 +0200
committerMarliana Lara <mlara@redhat.com>2017-10-02 19:35:32 +0200
commit5c5293783dd8d832ab5ad02347df6219f8dea35e (patch)
tree96df142001b6ccdadce117a3d1871eda8dc3554a
parentAdd Layout directive unit tests (diff)
downloadawx-5c5293783dd8d832ab5ad02347df6219f8dea35e.tar.xz
awx-5c5293783dd8d832ab5ad02347df6219f8dea35e.zip
Add Side Nav directive unit tests
-rw-r--r--awx/ui/client/test/unit/index.js1
-rw-r--r--awx/ui/client/test/unit/side-nav.spec.js46
2 files changed, 47 insertions, 0 deletions
diff --git a/awx/ui/client/test/unit/index.js b/awx/ui/client/test/unit/index.js
index 738fb8fe14..448f41b680 100644
--- a/awx/ui/client/test/unit/index.js
+++ b/awx/ui/client/test/unit/index.js
@@ -13,3 +13,4 @@ import '../../lib/models';
// Import tests
import './panel-body.spec';
import './layout.spec';
+import './side-nav.spec';
diff --git a/awx/ui/client/test/unit/side-nav.spec.js b/awx/ui/client/test/unit/side-nav.spec.js
new file mode 100644
index 0000000000..cfb1d61812
--- /dev/null
+++ b/awx/ui/client/test/unit/side-nav.spec.js
@@ -0,0 +1,46 @@
+describe('Components | Side Nav', () => {
+ let $compile;
+ let $rootScope;
+ let element;
+ let scope;
+
+ beforeEach(() => {
+ angular.mock.module('gettext');
+ angular.mock.module('I18N');
+ angular.mock.module('ui.router');
+ angular.mock.module('at.lib.services')
+ angular.mock.module('at.lib.components')
+ });
+
+ beforeEach(angular.mock.inject((_$compile_, _$rootScope_) => {
+ $compile = _$compile_;
+ $rootScope = _$rootScope_;
+ scope = $rootScope.$new();
+
+ element = angular.element("<at-layout><at-side-nav></at-side-nav><at-layout>");
+ element = $compile(element)(scope);
+ scope.$digest();
+ }));
+
+ describe('Side Nav Controller', () => {
+ let sideNav;
+ let sideNavCtrl;
+
+ beforeEach(() => {
+ sideNav = angular.element(element[0].querySelector('.at-Layout-side'));
+ sideNavCtrl = sideNav.controller('atSideNav');
+ });
+
+ it('isExpanded defaults to false', () => {
+ expect(sideNavCtrl.isExpanded).toBe(false);
+ });
+
+ it('toggleExpansion()', () => {
+ sideNavCtrl.toggleExpansion();
+ expect(sideNavCtrl.isExpanded).toBe(true);
+
+ sideNavCtrl.toggleExpansion();
+ expect(sideNavCtrl.isExpanded).toBe(false);
+ });
+ });
+});