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

19 lines
678 B
CoffeeScript
Raw Normal View History

LadderTabView = require 'views/play/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
request.response({status: 200, responseText: '{}'})
2014-06-30 22:16:26 -04:00
expect(triggered).toBe(true)