2014-12-08 17:21:40 -05:00
|
|
|
LadderTabView = require 'views/ladder/LadderTabView'
|
2014-06-06 19:46:42 -04:00
|
|
|
Level = require 'models/Level'
|
|
|
|
fixtures = require 'test/app/fixtures/levels'
|
|
|
|
|
|
|
|
describe 'LeaderboardData', ->
|
|
|
|
it 'triggers "sync" when its request is finished', ->
|
|
|
|
level = new Level(fixtures.LadderLevel)
|
|
|
|
leaderboard = new LadderTabView.LeaderboardData(level, 'humans', null, 4)
|
|
|
|
leaderboard.fetch()
|
2014-06-30 22:16:26 -04:00
|
|
|
|
2014-06-06 19:46:42 -04:00
|
|
|
# no session passed in, so only one request
|
|
|
|
expect(jasmine.Ajax.requests.count()).toBe(1)
|
2014-06-30 22:16:26 -04:00
|
|
|
|
2014-06-06 19:46:42 -04:00
|
|
|
request = jasmine.Ajax.requests.mostRecent()
|
|
|
|
triggered = false
|
|
|
|
leaderboard.once 'sync', -> triggered = true
|
2014-12-08 17:21:40 -05:00
|
|
|
request.respondWith({status: 200, responseText: '{}'})
|
2014-06-30 22:16:26 -04:00
|
|
|
expect(triggered).toBe(true)
|