Commit a9623064 by polesye

Fix js unit tests.

parent 524388db
...@@ -9,8 +9,10 @@ describe 'Calculator', -> ...@@ -9,8 +9,10 @@ describe 'Calculator', ->
it 'bind the help button', -> it 'bind the help button', ->
# These events are bind by $.hover() # These events are bind by $.hover()
expect($('div.help-wrapper a')).toHandleWith 'mouseover', @calculator.helpToggle expect($('div.help-wrapper a')).toHandle 'mouseover'
expect($('div.help-wrapper a')).toHandleWith 'mouseout', @calculator.helpToggle 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', -> it 'prevent default behavior on help button', ->
$('div.help-wrapper a').click (e) -> $('div.help-wrapper a').click (e) ->
...@@ -33,8 +35,8 @@ describe 'Calculator', -> ...@@ -33,8 +35,8 @@ describe 'Calculator', ->
# Since the focus is called asynchronously, we need to # Since the focus is called asynchronously, we need to
# wait until focus() is called. # wait until focus() is called.
didFocus = false didFocus = false
runs -> runs ->
spyOn($.fn, 'focus').andCallFake (elementName) -> didFocus = true spyOn($.fn, 'focus').andCallFake (elementName) -> didFocus = true
@calculator.toggle(jQuery.Event("click")) @calculator.toggle(jQuery.Event("click"))
waitsFor (-> didFocus), "focus() should have been called on the input", 1000 waitsFor (-> didFocus), "focus() should have been called on the input", 1000
...@@ -49,12 +51,14 @@ describe 'Calculator', -> ...@@ -49,12 +51,14 @@ describe 'Calculator', ->
@calculator.toggle(jQuery.Event("click")) @calculator.toggle(jQuery.Event("click"))
expect($('.calc')).not.toHaveClass('closed') expect($('.calc')).not.toHaveClass('closed')
describe 'helpToggle', -> describe 'helpShow', ->
it 'toggle the help overlay', -> it 'show the help overlay', ->
@calculator.helpToggle() @calculator.helpShow()
expect($('.help')).toHaveClass('shown') expect($('.help')).toHaveClass('shown')
@calculator.helpToggle() describe 'helpHide', ->
it 'show the help overlay', ->
@calculator.helpHide()
expect($('.help')).not.toHaveClass('shown') expect($('.help')).not.toHaveClass('shown')
describe 'calculate', -> describe 'calculate', ->
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment