From a962306419c17e3adf4356ab9328bfa47f2e57d9 Mon Sep 17 00:00:00 2001 From: polesye Date: Fri, 11 Oct 2013 13:37:15 +0300 Subject: [PATCH] Fix js unit tests. --- lms/static/coffee/spec/calculator_spec.coffee | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lms/static/coffee/spec/calculator_spec.coffee b/lms/static/coffee/spec/calculator_spec.coffee index 8258d8965a..81034bbd20 100644 --- a/lms/static/coffee/spec/calculator_spec.coffee +++ b/lms/static/coffee/spec/calculator_spec.coffee @@ -9,8 +9,10 @@ describe 'Calculator', -> it 'bind the help button', -> # These events are bind by $.hover() - expect($('div.help-wrapper a')).toHandleWith 'mouseover', @calculator.helpToggle - expect($('div.help-wrapper a')).toHandleWith 'mouseout', @calculator.helpToggle + expect($('div.help-wrapper a')).toHandle 'mouseover' + expect($('div.help-wrapper a')).toHandle 'mouseout' + expect($('div.help-wrapper')).toHandle 'focusin' + expect($('div.help-wrapper')).toHandle 'focusout' it 'prevent default behavior on help button', -> $('div.help-wrapper a').click (e) -> @@ -33,8 +35,8 @@ describe 'Calculator', -> # Since the focus is called asynchronously, we need to # wait until focus() is called. didFocus = false - runs -> - spyOn($.fn, 'focus').andCallFake (elementName) -> didFocus = true + runs -> + spyOn($.fn, 'focus').andCallFake (elementName) -> didFocus = true @calculator.toggle(jQuery.Event("click")) waitsFor (-> didFocus), "focus() should have been called on the input", 1000 @@ -49,12 +51,14 @@ describe 'Calculator', -> @calculator.toggle(jQuery.Event("click")) expect($('.calc')).not.toHaveClass('closed') - describe 'helpToggle', -> - it 'toggle the help overlay', -> - @calculator.helpToggle() + describe 'helpShow', -> + it 'show the help overlay', -> + @calculator.helpShow() expect($('.help')).toHaveClass('shown') - @calculator.helpToggle() + describe 'helpHide', -> + it 'show the help overlay', -> + @calculator.helpHide() expect($('.help')).not.toHaveClass('shown') describe 'calculate', ->