describe "directives", -> beforeEach module("mb.directives") $scope = null element = null describe "osEsc", -> beforeEach inject ($compile, $rootScope) -> $scope = $rootScope.$new() $scope.bar = -> element = $compile('')($scope) $scope.$digest() it "calls the given function when the ESC was pressed", -> spyOn($scope, 'bar') event = jQuery.Event("keyup", keyCode: 27) element.trigger(event) expect($scope.bar).toHaveBeenCalled() it "does nothing on other keys", -> spyOn($scope, 'bar') event = jQuery.Event("keyup", keyCode: 13) element.trigger(event) expect($scope.bar).not.toHaveBeenCalled() describe "deleteButton", -> beforeEach inject ($compile, $rootScope) -> $scope = $rootScope.$new() $scope.bar = -> template = """