diff --git a/src/components/sidenav/sidenav.js b/src/components/sidenav/sidenav.js index 34aea7d12d4..ba70b2ec916 100644 --- a/src/components/sidenav/sidenav.js +++ b/src/components/sidenav/sidenav.js @@ -42,7 +42,7 @@ angular.module('material.components.sidenav', [ */ function SidenavService($mdComponentRegistry, $q) { return function(handle) { - var errorMsg = "SideNav '" + handle + "' is not availabe!"; + var errorMsg = "SideNav '" + handle + "' is not available!"; // Lookup the controller instance for the specified sidNav instance var instance = $mdComponentRegistry.get(handle); @@ -275,7 +275,7 @@ function SidenavController($scope, $element, $attrs, $mdComponentRegistry, $q) { // Use Default internal method until overridden by directive postLink - self.$toggleOpen = function() { return $q.when($scope.isOpen) }; + self.$toggleOpen = function() { return $q.when($scope.isOpen); }; self.isOpen = function() { return !!$scope.isOpen; }; self.open = function() { return self.$toggleOpen( true ); }; self.close = function() { return self.$toggleOpen( false ); }; diff --git a/src/components/sidenav/sidenav.spec.js b/src/components/sidenav/sidenav.spec.js index 52ca9b24b84..c7a4a13d55e 100644 --- a/src/components/sidenav/sidenav.spec.js +++ b/src/components/sidenav/sidenav.spec.js @@ -38,7 +38,7 @@ describe('mdSidenav', function() { $animate.triggerCallbacks(); el.parent().triggerHandler({ type: 'keydown', - keyCode: $mdConstant.KEY_CODE.ESCAPE + keyCode: $mdConstant.KEY_CODE.ESCAPE }); $timeout.flush(); expect($rootScope.show).toBe(false); @@ -142,30 +142,36 @@ describe('mdSidenav', function() { var controller = el.controller('mdSidenav'); var openDone = 0, closeDone = 0, toggleDone = 0; - var onDone = function() { openDone++; }; + var onOpen = function() { openDone++; }; var onClose = function() { closeDone++; }; var onToggle = function() { toggleDone++; }; - controller.open() - .then( onDone ) - .then( controller.close ) - .then( onClose ); + controller + .open() + .then(onOpen) + .then(controller.close) + .then(onClose); flush(); expect(openDone).toBe(1); + flush(); + expect(closeDone).toBe(1); + controller + .close() + .then(onClose); - controller.close() - .then( onClose ); flush(); + expect(closeDone).toBe(2); expect(scope.isOpen).toBe(false); + controller + .toggle() + .then(onToggle); - controller.toggle() - .then( onToggle ); flush(); + expect(toggleDone).toBe(1); expect(scope.isOpen).toBe(true); - }); @@ -174,14 +180,14 @@ describe('mdSidenav', function() { var controller = el.controller('mdSidenav'); var openDone = 0, closeDone = 0; - var onDone = function() { openDone++; }; + var onOpen = function() { openDone++; }; var onClose = function() { closeDone++; }; controller .open() - .then(onDone) + .then(onOpen) .then(controller.open) - .then(onDone); + .then(onOpen); flush(); expect(openDone).toBe(2);