mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-12-12 08:41:46 -05:00
d20600b381
Don’t show not-started unlocked levels if previous incomplete practice level is available Yellow arrow points at adventurer levels too now Closes #3882
37 lines
1.5 KiB
CoffeeScript
37 lines
1.5 KiB
CoffeeScript
factories = require 'test/app/factories'
|
|
CampaignView = require 'views/play/CampaignView'
|
|
Levels = require 'collections/Levels'
|
|
|
|
describe 'CampaignView', ->
|
|
|
|
describe 'when 4 earned levels', ->
|
|
beforeEach ->
|
|
@campaignView = new CampaignView()
|
|
@campaignView.levelStatusMap = {}
|
|
levels = new Levels(_.times(4, -> factories.makeLevel()))
|
|
@campaignView.campaign = factories.makeCampaign({}, {levels})
|
|
@levels = (level.toJSON() for level in levels.models)
|
|
earned = me.get('earned') or {}
|
|
earned.levels ?= []
|
|
earned.levels.push(level.original) for level in @levels
|
|
me.set('earned', earned)
|
|
|
|
describe 'and 3rd one is practice', ->
|
|
beforeEach ->
|
|
@levels[2].practice = true
|
|
@campaignView.annotateLevels(@levels)
|
|
it 'hides next levels if there are practice levels to do', ->
|
|
expect(@levels[2].hidden).toEqual(false)
|
|
expect(@levels[3].hidden).toEqual(true)
|
|
|
|
describe 'and 2nd rewards a practice a non-practice level', ->
|
|
beforeEach ->
|
|
@campaignView.levelStatusMap[@levels[0].slug] = 'complete'
|
|
@campaignView.levelStatusMap[@levels[1].slug] = 'complete'
|
|
@levels[1].rewards = [{level: @levels[2].original}, {level: @levels[3].original}]
|
|
@levels[2].practice = true
|
|
@campaignView.annotateLevels(@levels)
|
|
@campaignView.determineNextLevel(@levels)
|
|
it 'points at practice level first', ->
|
|
expect(@levels[2].next).toEqual(true)
|
|
expect(@levels[3].next).not.toBeDefined(true)
|