mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-01 00:15:00 -04:00
Fixed Level denormalize test.
This commit is contained in:
parent
ba1e7005ca
commit
03e39c3f5c
1 changed files with 8 additions and 6 deletions
|
@ -17,6 +17,7 @@ describe 'Level', ->
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
type: 'hero'
|
||||||
})
|
})
|
||||||
|
|
||||||
thangType = new ThangType({
|
thangType = new ThangType({
|
||||||
|
@ -28,17 +29,17 @@ describe 'Level', ->
|
||||||
{"original": "d", "majorVersion": 0, "config": {i: 1}}
|
{"original": "d", "majorVersion": 0, "config": {i: 1}}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
supermodel = new SuperModel()
|
supermodel = new SuperModel()
|
||||||
supermodel.registerModel(thangType)
|
supermodel.registerModel(thangType)
|
||||||
|
|
||||||
result = level.denormalize(supermodel)
|
result = level.denormalize(supermodel)
|
||||||
tharinThangComponents = result.thangs[0].components
|
tharinThangComponents = result.thangs[0].components
|
||||||
|
|
||||||
it 'adds default configs to thangs without any config', ->
|
it 'adds default configs to thangs without any config', ->
|
||||||
aComp = _.find tharinThangComponents, {original:'a'}
|
aComp = _.find tharinThangComponents, {original:'a'}
|
||||||
expect(_.isEqual(aComp.config, {i:1})).toBeTruthy()
|
expect(_.isEqual(aComp.config, {i:1})).toBeTruthy()
|
||||||
|
|
||||||
it 'leaves alone configs for components the level thang has but the thang type does not', ->
|
it 'leaves alone configs for components the level thang has but the thang type does not', ->
|
||||||
bComp = _.find tharinThangComponents, {original:'b'}
|
bComp = _.find tharinThangComponents, {original:'b'}
|
||||||
expect(_.isEqual(bComp.config, {i:2})).toBeTruthy()
|
expect(_.isEqual(bComp.config, {i:2})).toBeTruthy()
|
||||||
|
@ -46,7 +47,8 @@ describe 'Level', ->
|
||||||
it 'merges configs where both the level thang and thang type have one, giving priority to the level thang', ->
|
it 'merges configs where both the level thang and thang type have one, giving priority to the level thang', ->
|
||||||
cComp = _.find tharinThangComponents, {original:'c'}
|
cComp = _.find tharinThangComponents, {original:'c'}
|
||||||
expect(_.isEqual(cComp.config, {i: 1, ii: 2, nest: {iii: 3, iv: 4}})).toBeTruthy()
|
expect(_.isEqual(cComp.config, {i: 1, ii: 2, nest: {iii: 3, iv: 4}})).toBeTruthy()
|
||||||
|
|
||||||
it 'adds components from the thang type that do not exist in the level thang', ->
|
it 'adds components from the thang type that do not exist in the level thang', ->
|
||||||
dComp = _.find tharinThangComponents, {original:'d'}
|
dComp = _.find tharinThangComponents, {original:'d'}
|
||||||
expect(_.isEqual(dComp.config, {i: 1})).toBeTruthy()
|
expect(dComp).toBeTruthy()
|
||||||
|
expect(_.isEqual(dComp?.config, {i: 1})).toBeTruthy()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue