Refactor the SAYT code to return better results

This commit is contained in:
Andrew Miner
2015-01-15 17:12:12 -08:00
parent a50e3d9621
commit d94bd39e52
7 changed files with 87 additions and 85 deletions
-27
View File
@@ -99,33 +99,6 @@ describe 'ModPack', ->
display.itemName.should.equal 'Iron Chestplate'
display.modSlug.should.equal 'minecraft'
describe 'gatherNames', ->
it 'finds all registered item names', ->
buildcraft.enabled = true
industrialCraft.enabled = true
(i.value for i in modPack.gatherNames()).sort().should.eql ['Bed', 'Rubber', 'Stone Gear']
it 'ignores duplicate item names', ->
buildcraft.enabled = true
names = modPack.gatherNames()
bedName = (e for e in names when e.value is 'Bed')[0]
bedName.should.eql value:'Bed', label:'Bed (from Minecraft 1.7.10)'
it 'alphabetizes the item names', ->
buildcraft.enabled = true
industrialCraft.enabled = true
(i.value for i in modPack.gatherNames()).should.eql ['Bed', 'Rubber', 'Stone Gear']
it 'ignores non-craftable items', ->
(n.value for n in modPack.gatherNames()).sort().should.eql ['Bed']
it 'ignores disabled mod versions', ->
(n.value for n in modPack.gatherNames()).should.not.include 'Stone Gear'
it "doesn't ignore disabled mod versions when include disabled is requested", ->
(n.value for n in modPack.gatherNames(includeDisabled:true)).should.include 'Stone Gear'
describe 'hasRecipe', ->
it 'returns true when the item is present and has recipes', ->
-21
View File
@@ -59,27 +59,6 @@ describe 'ModVersion', ->
new Item modVersion:modVersion, name:'Crafting Table'
modVersion.findItemByName('Crafting Table').slug.should.equal 'crafting_table'
describe 'gatherNames', ->
it 'skips names already found', ->
new Item modVersion:modVersion, name:'Wool'
new Item modVersion:modVersion, name:'Oak Wood Planks', recipes:['foo']
names = modVersion.gatherNames {wool:true}
names.wool.should.be.true
names.oak_wood_planks.value.should.equal 'Oak Wood Planks'
it 'only includes craftable items', ->
new Item modVersion:modVersion, name:'Wool'
new Item modVersion:modVersion, name:'Oak Wood Planks', recipes:['foo']
names = modVersion.gatherNames()
_.keys(names).should.eql ['oak_wood_planks']
it 'computes the proper value and label', ->
new Item modVersion:modVersion, name:'Oak Wood Planks', recipes:['foo']
names = modVersion.gatherNames()
names.oak_wood_planks.value.should.equal 'Oak Wood Planks'
names.oak_wood_planks.label.should.equal 'Oak Wood Planks (from Test 0.0)'
describe 'hasRecipe', ->
it 'returns false for an unknown item', ->