Transition onblur tests
Project: http://git-wip-us.apache.org/repos/asf/climate/repo Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/ce9715b3 Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/ce9715b3 Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/ce9715b3 Branch: refs/heads/master Commit: ce9715b3b190928e534092df790b5353b7d21ea8 Parents: b82ec78 Author: Michael Joyce <[email protected]> Authored: Sun Jul 27 10:53:52 2014 -0700 Committer: Michael Joyce <[email protected]> Committed: Mon Aug 4 15:01:02 2014 -0700 ---------------------------------------------------------------------- .../frontend-new/test/spec/directives/onblur.js | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/climate/blob/ce9715b3/ocw-ui/frontend-new/test/spec/directives/onblur.js ---------------------------------------------------------------------- diff --git a/ocw-ui/frontend-new/test/spec/directives/onblur.js b/ocw-ui/frontend-new/test/spec/directives/onblur.js index bc1c49d..7e8b83a 100644 --- a/ocw-ui/frontend-new/test/spec/directives/onblur.js +++ b/ocw-ui/frontend-new/test/spec/directives/onblur.js @@ -31,9 +31,20 @@ describe('Directive: onBlur', function () { scope = $rootScope.$new(); })); - it('should make hidden element visible', inject(function ($compile) { - element = angular.element('<on-blur></on-blur>'); - element = $compile(element)(scope); - expect(element.text()).toBe('this is the onBlur directive'); - })); + it('should call the supplied function on the blur event', function() { + inject(function($compile) { + // Set a scope variable to make sure that on-blur calls + // the function that we pass to it. + scope.bogusFunction = function() { + scope.test = "hi" + } + + var element = angular.element('<input on-blur="bogusFunction();" />') + element = $compile(element)(scope) + + expect(scope.test).toNotBe('hi'); + element.triggerHandler('blur'); + expect(scope.test).toBe('hi'); + }); + }); });
