Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(sidenav): Fix tests and typo
Browse files Browse the repository at this point in the history
  • Loading branch information
gkalpak authored and ThomasBurleson committed Dec 22, 2014
1 parent 3c05463 commit c0e2b0f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/components/sidenav/sidenav.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ); };
Expand Down
34 changes: 20 additions & 14 deletions src/components/sidenav/sidenav.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);

});


Expand All @@ -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);
Expand Down

0 comments on commit c0e2b0f

Please sign in to comment.