Skip to content

Instantly share code, notes, and snippets.

@ivan-hilckov
Created July 25, 2012 12:40
Show Gist options
  • Select an option

  • Save ivan-hilckov/3175960 to your computer and use it in GitHub Desktop.

Select an option

Save ivan-hilckov/3175960 to your computer and use it in GitHub Desktop.
test
suite "Election.Menu", ->
setup ->
@app = new Elections.App
@menu = Elections.Menu.init( el: ".menu", app: @app )
sinon.spy( @menu, "activateMenuItem" )
sinon.spy( @menu, "deactivateMenuItem" )
test "событие viewOpen", ->
view = {}
@app.trigger "viewOpen", view
assert.ok @menu.activateMenuItem.calledWithExactly view
@menu.activateMenuItem.restore()
@menu.deactivateMenuItem.restore()
test "событие viewClose", ->
view = {}
@app.trigger "viewOpen", view
assert.ok @menu.activateMenuItem.calledWithExactly view
@menu.activateMenuItem.restore()
@menu.deactivateMenuItem.restore()
suite "#openMenuItem", ->
setup ->
@menu_html = $("<ul class='menu'><li class='active'><a href='#item1'>1</a></li><li class='not-active'><a href='#item2'>2</a></li></ul>")
@app = new Elections.App
sinon.spy( @app.router, "gotoBack" )
@menu = Elections.Menu.init( el: @menu_html, app: @app )
test "openMenuItem", ->
@menu_html.find( "a[ href *= #item1 ]" ).click()
@menu_html.find( "a[ href *= #item2 ]" ).click()
assert.ok @app.router.gotoBack.calledOnce
@app.router.gotoBack.restore()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment