codecombat/test/app/views/play/ladder/LadderTabView.spec.coffee

19 lines
661 B
CoffeeScript
Raw Normal View History

LadderTabView = require 'views/ladder/LadderTabView'
2014-06-06 19:46:42 -04:00
Level = require 'models/Level'
factories = require 'test/app/factories'
2014-06-06 19:46:42 -04:00
describe 'LeaderboardData', ->
it 'triggers "sync" when its request is finished', ->
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
request.respondWith({status: 200, responseText: '{}'})
2014-06-30 22:16:26 -04:00
expect(triggered).toBe(true)