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'
|
2016-05-03 13:38:20 -04:00
|
|
|
factories = require 'test/app/factories'
|
2014-06-06 19:46:42 -04:00
|
|
|
|
|
|
|
describe 'LeaderboardData', ->
|
|
|
|
it 'triggers "sync" when its request is finished', ->
|
2016-05-03 13:38:20 -04:00
|
|
|
level = factories.makeLevel()
|
2014-06-06 19:46:42 -04:00
|
|
|
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)
|