Fix broken tests for gatherNames

This commit is contained in:
Andrew Miner
2015-01-10 12:13:43 -08:00
parent 9756f1f045
commit 9970b92157
3 changed files with 12 additions and 12 deletions
+1 -1
View File
@@ -58,7 +58,7 @@ module.exports = class ModVersion extends BaseModel
for slug, item of @items for slug, item of @items
continue if result[item.slug] continue if result[item.slug]
if item.isGatherable if not item.isCraftable
continue unless options.includeGatherable continue unless options.includeGatherable
result[item.slug] = value:item.name, label:"#{item.name} (from #{@name} #{@version})" result[item.slug] = value:item.name, label:"#{item.name} (from #{@name} #{@version})"
+7 -7
View File
@@ -99,32 +99,32 @@ describe 'ModPack', ->
display.itemName.should.equal 'Iron Chestplate' display.itemName.should.equal 'Iron Chestplate'
display.modSlug.should.equal 'minecraft' display.modSlug.should.equal 'minecraft'
describe 'gatherRecipeNames', -> describe 'gatherNames', ->
it 'finds all registered item names', -> it 'finds all registered item names', ->
buildcraft.enabled = true buildcraft.enabled = true
industrialCraft.enabled = true industrialCraft.enabled = true
(i.value for i in modPack.gatherRecipeNames()).sort().should.eql ['Bed', 'Rubber', 'Stone Gear'] (i.value for i in modPack.gatherNames()).sort().should.eql ['Bed', 'Rubber', 'Stone Gear']
it 'ignores duplicate item names', -> it 'ignores duplicate item names', ->
buildcraft.enabled = true buildcraft.enabled = true
names = modPack.gatherRecipeNames() names = modPack.gatherNames()
bedName = (e for e in names when e.value is 'Bed')[0] bedName = (e for e in names when e.value is 'Bed')[0]
bedName.should.eql value:'Bed', label:'Bed (from Minecraft 1.7.10)' bedName.should.eql value:'Bed', label:'Bed (from Minecraft 1.7.10)'
it 'alphabetizes the item names', -> it 'alphabetizes the item names', ->
buildcraft.enabled = true buildcraft.enabled = true
industrialCraft.enabled = true industrialCraft.enabled = true
(i.value for i in modPack.gatherRecipeNames()).should.eql ['Bed', 'Rubber', 'Stone Gear'] (i.value for i in modPack.gatherNames()).should.eql ['Bed', 'Rubber', 'Stone Gear']
it 'ignores non-craftable items', -> it 'ignores non-craftable items', ->
(n.value for n in modPack.gatherRecipeNames()).sort().should.eql ['Bed'] (n.value for n in modPack.gatherNames()).sort().should.eql ['Bed']
it 'ignores disabled mod versions', -> it 'ignores disabled mod versions', ->
(n.value for n in modPack.gatherRecipeNames()).should.not.include 'Stone Gear' (n.value for n in modPack.gatherNames()).should.not.include 'Stone Gear'
it "doesn't ignore disabled mod versions when include disabled is requested", -> it "doesn't ignore disabled mod versions when include disabled is requested", ->
(n.value for n in modPack.gatherRecipeNames(includeDisabled:true)).should.include 'Stone Gear' (n.value for n in modPack.gatherNames(includeDisabled:true)).should.include 'Stone Gear'
describe 'hasRecipe', -> describe 'hasRecipe', ->
+4 -4
View File
@@ -59,24 +59,24 @@ describe 'ModVersion', ->
modVersion.addItem new Item name:'Crafting Table' modVersion.addItem new Item name:'Crafting Table'
modVersion.findItemByName('Crafting Table').slug.should.equal 'crafting_table' modVersion.findItemByName('Crafting Table').slug.should.equal 'crafting_table'
describe 'gatherRecipeNames', -> describe 'gatherNames', ->
it 'skips names already found', -> it 'skips names already found', ->
modVersion.addItem new Item name:'Wool' modVersion.addItem new Item name:'Wool'
modVersion.addItem new Item name:'Oak Wood Planks', recipes:['foo'] modVersion.addItem new Item name:'Oak Wood Planks', recipes:['foo']
names = modVersion.gatherRecipeNames {wool:true} names = modVersion.gatherNames {wool:true}
names.wool.should.be.true names.wool.should.be.true
names.oak_wood_planks.value.should.equal 'Oak Wood Planks' names.oak_wood_planks.value.should.equal 'Oak Wood Planks'
it 'only includes craftable items', -> it 'only includes craftable items', ->
modVersion.addItem new Item name:'Wool' modVersion.addItem new Item name:'Wool'
modVersion.addItem new Item name:'Oak Wood Planks', recipes:['foo'] modVersion.addItem new Item name:'Oak Wood Planks', recipes:['foo']
names = modVersion.gatherRecipeNames() names = modVersion.gatherNames()
_.keys(names).should.eql ['oak_wood_planks'] _.keys(names).should.eql ['oak_wood_planks']
it 'computes the proper value and label', -> it 'computes the proper value and label', ->
modVersion.addItem new Item name:'Oak Wood Planks', recipes:['foo'] modVersion.addItem new Item name:'Oak Wood Planks', recipes:['foo']
names = modVersion.gatherRecipeNames() names = modVersion.gatherNames()
names.oak_wood_planks.value.should.equal 'Oak Wood Planks' names.oak_wood_planks.value.should.equal 'Oak Wood Planks'
names.oak_wood_planks.label.should.equal 'Oak Wood Planks (from Test 0.0)' names.oak_wood_planks.label.should.equal 'Oak Wood Planks (from Test 0.0)'