Permalink
Browse files

Add spec for issue #8

  • Loading branch information...
1 parent 4ac0289 commit 011f0776b320b74854b579869cb325ae81cd9c47 @kossnocorp committed Nov 28, 2012
Showing with 22 additions and 0 deletions.
  1. +22 −0 spec/jquery.turbolinks_spec.coffee
@@ -13,6 +13,10 @@ $ = require('jquery')
chai.should()
chai.use(sinonChai)
+getUniqId = do ->
+ counter = 0
+ -> 'id_' + (counter += 1)
+
describe '$ Turbolinks', ->
callback1 = callback2 = null
@@ -42,6 +46,24 @@ describe '$ Turbolinks', ->
callback1.should.have.been.calledWith($)
+ it '''
+ should remove all events delegated to
+ document after trigger fetch
+ ''', ->
+ id = getUniqId()
+ selector = '#' + id
+ addEl = ->
+ $('body').empty()
+ $('<div>').attr(id: id).appendTo('body')
+
+ addEl()
+ $(document).on('event_name', selector, callback1)
+ $(selector).trigger('event_name')
+ $(document).trigger('page:fetch')
+ addEl()
+ $(selector).trigger('event_name')
+ callback1.should.have.been.calledOnce
+
describe '$.setReadyEvent', ->
beforeEach ->

0 comments on commit 011f077

Please sign in to comment.