Configuration tests added updated to match

master
Oversword 2021-10-17 01:06:05 +01:00
parent 104a9d9a21
commit 8ba3f849ed
45 changed files with 484 additions and 11 deletions

View File

@ -1,3 +1,4 @@
default
mobs
config
config
test?

View File

@ -83,3 +83,6 @@ if mod_config.bat.spawn.enabled then
end
mobs:register_egg("mobs_bat:bat", "Bat", "animal_bat_inv.png", 0)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_bat/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Bat Mob", function ()
describe("Bat", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_bat:bat", { "air" }, { "default:stone" }, 0, 6, 30, 300000, 2, -25000, 5000)
end)
end)
end)
test.execute(true)

View File

@ -1,2 +1,3 @@
mobs
farming?
test?

View File

@ -10,7 +10,7 @@ local mod_config = config.settings_model('mobs_bear', {
chance = config.types.int(300000, { min=1 }),
min_light = config.types.int(10, { min=0 }),
max_light = config.types.int(15, { min=0 }),
min_height = config.types.int(-10, { min=-31000, max=31000 }),
min_height = config.types.int(-9, { min=-31000, max=31000 }),
max_height = config.types.int(5000, { min=-31000, max=31000 }),
active_object_count = config.types.int(1, { min=1 }),
}
@ -135,3 +135,6 @@ if mod_config.medved.spawn.enabled then
end
mobs:register_egg("mobs_bear:medved", "Bear", "wool_brown.png", 1)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_bear/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Bear Mob", function ()
describe("Medved", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_bear:medved", { "default:dirt_with_grass", "ethereal:green_dirt_top" }, { "air" }, 10, 15, 30, 300000, 1, -9, 5000, true)
end)
end)
end)
test.execute(true)

View File

@ -1,3 +1,4 @@
mobs
mobs_mr_goat?
farming?
test?

View File

@ -94,3 +94,6 @@ if mod_config.rat.spawn.enabled then
end
mobs:register_egg("mobs_better_rat:rat", "Mouse", "wool_brown.png", 1)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_better_rat/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Better Rat Mob", function ()
describe("Better Rat", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_better_rat:rat", { "default:stone" }, { "air" }, 0, 14, 30, 300000, 2, -25000, 5000)
end)
end)
end)
test.execute(true)

View File

@ -1,2 +1,3 @@
default
mobs
test?

View File

@ -102,7 +102,7 @@ mobs:register_mob("mobs_birds:gull", {
{name="mobs:chicken_feather", chance=1, min=0, max=2}
},
})
if mod_config.gull.spawn.enbaled then
if mod_config.gull.spawn.enabled then
--name, nodes, neighbors, min_light, max_light, interval, chance, active_object_count, min_height, max_height
mobs:spawn_specific(
"mobs_birds:gull",
@ -214,3 +214,6 @@ if mod_config.bird_sm.spawn.enabled then
)
end
mobs:register_egg("mobs_birds:bird_sm", "Small bird", l_egg_texture, 1)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

29
mobs_birds/test.lua Normal file
View File

@ -0,0 +1,29 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Birds Mob", function ()
describe("Birds", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_birds:bird_lg", { "air" }, { "default:leaves", "default:pine_needles", "default:jungleleaves", "default:cactus" }, 5, 20, 30, 360000, 1, 0, 5000)
stub_spawn_specific.called_with(mobs, "mobs_birds:gull", { "air" }, { "default:water_source", "default:water_flowing" }, 5, 20, 30, 240000, 1, 0, 5000)
stub_spawn_specific.called_with(mobs, "mobs_birds:bird_sm", { "air" }, { "default:leaves", "default:pine_needles", "default:jungleleaves", "default:cactus" }, 5, 20, 30, 360000, 1, 0, 5000)
end)
end)
end)
test.execute(true)

View File

@ -1,2 +1,3 @@
mobs
farming?
test?

View File

@ -105,3 +105,6 @@ if mod_config.bug.spawn.enabled then
end
mobs:register_egg("mobs_bugslive:bug", "Bug", "inv_bug.png", 0)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_bugslive/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("BugsLive Mob", function ()
describe("BugsLive", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_bugslive:bug", { "default:dirt", "default:dirt_with_grass", "default:dirt_with_coniferous_litter", "default:dirt_with_dry_grass", "default:dirt_with_rainforest_litter", "default:stone", "ethereal:green_dirt_top" }, { "air", "default:water_source", "default:water_flowing", "default:river_water_source", "default:river_water_flowing" }, 0, 15, 30, 300000, 2, -25000, 5000)
end)
end)
end)
test.execute(true)

View File

@ -1,2 +1,3 @@
default
mobs
test?

View File

@ -74,3 +74,6 @@ if mod_config.butterfly.spawn.enabled then
end
mobs:register_egg("mobs_butterfly:butterfly", "Butterfly", "default_cloud.png", 1)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_butterfly/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Butterfly Mob", function ()
describe("Butterfly", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_butterfly:butterfly", { "air" }, { "group:flower" }, 5, 20, 30, 300000, 1, 0, 5000)
end)
end)
end)
test.execute(true)

View File

@ -1,2 +1,3 @@
mobs
farming?
test?

View File

@ -14,7 +14,7 @@ local mod_config = config.settings_model('mobs_deer', {
chance = config.types.int(300000, { min=1 }),
min_light = config.types.int(10, { min=0 }),
max_light = config.types.int(15, { min=0 }),
min_height = config.types.int(1, { min=-31000, max=31000 }),
min_height = config.types.int(2, { min=-31000, max=31000 }),
max_height = config.types.int(5000, { min=-31000, max=31000 }),
active_object_count = config.types.int(1, { min=1 }),
}
@ -99,3 +99,6 @@ if mod_config.deer.spawn.enabled then
end
mobs:register_egg("mobs_deer:deer", "Deer", "wool_violet.png", 1)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_deer/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Deer Mob", function ()
describe("Deer", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_deer:deer", { "default:dirt_with_grass", "default:dirt_with_coniferous_litter", "ethereal:green_dirt_top" }, { "air" }, 10, 15, 30, 300000, 1, 2, 5000, true)
end)
end)
end)
test.execute(true)

View File

@ -1,4 +1,5 @@
default
mobs
wool
farming?
farming?
test?

View File

@ -42,3 +42,6 @@ local mobslist = {
for _,mobname in pairs(mobslist) do
loadmob(mobname)
end
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

33
mobs_doomed/test.lua Normal file
View File

@ -0,0 +1,33 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Doomed Mob", function ()
describe("Doomed", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_doomed:badger", { "default:dirt_with_grass", "default:dirt", "default:dirt_with_coniferous_litter" }, { "air" }, 0, 14, 30, 300000, 2, 0, 5000)
stub_spawn_specific.called_with(mobs, "mobs_doomed:elephant", { "default:dirt_with_dry_grass", "default:desert_sand" }, { "air" }, 10, 14, 30, 300000, 2, 0, 5000, true)
stub_spawn_specific.called_with(mobs, "mobs_doomed:fox", { "default:dirt_with_grass", "default:dirt", "default:dirt_with_coniferous_litter", "default:dirt_with_snow" }, { "air" }, 0, 14, 30, 300000, 2, 0, 5000)
stub_spawn_specific.called_with(mobs, "mobs_doomed:hedgehog", { "default:dirt_with_grass", "default:dirt_with_coniferous_litter" }, { "air" }, 0, 14, 30, 300000, 2, 0, 5000)
stub_spawn_specific.called_with(mobs, "mobs_doomed:owl", { "group:leaves" }, { "air" }, 0, 14, 30, 300000, 2, 0, 5000, false)
stub_spawn_specific.called_with(mobs, "mobs_doomed:tortoise", { "default:clay", "group:sand" }, { "air" }, 10, 14, 30, 300000, 2, 0, 5000, true)
stub_spawn_specific.called_with(mobs, "mobs_doomed:whale", { "default:water_source" }, { "default:water_source" }, 0, 14, 30, 3000000, 1, -40, 0, true)
end)
end)
end)
test.execute(true)

View File

@ -1,2 +1,3 @@
default
mobs
test?

View File

@ -11,7 +11,7 @@ local mod_config = config.settings_model('mobs_fish', {
min_light = config.types.int(5, { min=0 }),
max_light = config.types.int(20, { min=0 }),
min_height = config.types.int(-50, { min=-31000, max=31000 }),
max_height = config.types.int(-1, { min=-31000, max=31000 }),
max_height = config.types.int(0, { min=-31000, max=31000 }),
active_object_count = config.types.int(1, { min=1 }),
}
},
@ -25,7 +25,7 @@ local mod_config = config.settings_model('mobs_fish', {
min_light = config.types.int(5, { min=0 }),
max_light = config.types.int(20, { min=0 }),
min_height = config.types.int(-50, { min=-31000, max=31000 }),
max_height = config.types.int(-1, { min=-31000, max=31000 }),
max_height = config.types.int(0, { min=-31000, max=31000 }),
active_object_count = config.types.int(1, { min=1 }),
}
}
@ -144,3 +144,6 @@ if mod_config.tropical.spawn.enabled then
)
end
mobs:register_egg("mobs_fish:tropical", "Tropical fish", "animal_fish_blue_white_fish_blue_white_item.png", 0)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

28
mobs_fish/test.lua Normal file
View File

@ -0,0 +1,28 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Fish Mob", function ()
describe("Fish", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_fish:clownfish", { "default:water_source", "default:water_flowing", "default:river_water_source", "default:river_water_flowing" }, { "default:sand", "default:dirt", "group:seaplants", "group:seacoral" }, 5, 20, 30, 100000, 1, -50, 0)
stub_spawn_specific.called_with(mobs, "mobs_fish:tropical", { "default:water_source", "default:water_flowing", "default:river_water_source", "default:river_water_flowing" }, { "default:sand", "default:dirt", "group:seaplants", "group:seacoral" }, 5, 20, 30, 100000, 1, -50, 0)
end)
end)
end)
test.execute(true)

View File

@ -1 +1,2 @@
mobs
test?

View File

@ -10,7 +10,7 @@ local mod_config = config.settings_model('mobs_giraffe', {
chance = config.types.int(300000, { min=1 }),
min_light = config.types.int(10, { min=0 }),
max_light = config.types.int(15, { min=0 }),
min_height = config.types.int(1, { min=-31000, max=31000 }),
min_height = config.types.int(2, { min=-31000, max=31000 }),
max_height = config.types.int(5000, { min=-31000, max=31000 }),
active_object_count = config.types.int(1, { min=1 }),
}
@ -97,3 +97,6 @@ if mod_config.jeraf.spawn.enabled then
end
mobs:register_egg("mobs_giraffe:jeraf", "Giraffe", "wool_yellow.png", 1)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_giraffe/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Giraffe Mob", function ()
describe("Jeraf", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_giraffe:jeraf", { "default:sand", "default:desert_sand", "default:dirt_with_dry_grass" }, { "air" }, 10, 15, 30, 300000, 1, 2, 5000, true)
end)
end)
end)
test.execute(true)

View File

@ -1,3 +1,3 @@
default
mobs
test?

View File

@ -67,3 +67,6 @@ if mod_config.jellyfish.spawn.enabled then
end
mobs:register_egg("mobs_jellyfish:jellyfish", "Jellyfish", "jellyfish_inv.png", 0)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_jellyfish/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Jellyfish Mob", function ()
describe("Jellyfish", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_jellyfish:jellyfish", { "default:water_source" }, { "default:water_flowing", "default:water_source" }, 1, 14, 30, 300000, 1, -50, -1)
end)
end)
end)
test.execute(true)

View File

@ -1,3 +1,4 @@
mobs
mobs_animal
farming?
test?

View File

@ -10,7 +10,7 @@ local mod_config = config.settings_model('mobs_mr_goat', {
chance = config.types.int(300000, { min=1 }),
min_light = config.types.int(10, { min=0 }),
max_light = config.types.int(15, { min=0 }),
min_height = config.types.int(1, { min=-31000, max=31000 }),
min_height = config.types.int(2, { min=-31000, max=31000 }),
max_height = config.types.int(5000, { min=-31000, max=31000 }),
active_object_count = config.types.int(1, { min=1 }),
}
@ -160,3 +160,6 @@ minetest.register_craft({
{'mobs_mr_goat:goatcheeseblock'}
}
})
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_mr_goat/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Mr Goat Mob", function ()
describe("Mr Goat", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_mr_goat:goat", { "default:dirt_with_grass", "ethereal:green_dirt_top" }, { "air" }, 10, 15, 30, 300000, 1, 2, 5000, true)
end)
end)
end)
test.execute(true)

View File

@ -1,2 +1,3 @@
default
mobs
test?

View File

@ -196,3 +196,5 @@ if mod_config.seaturtle.spawn.enabled then
)
end
mobs:register_egg("mobs_turtles:seaturtle", "Sea Turtle", "default_water.png", 1)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

28
mobs_turtles/test.lua Normal file
View File

@ -0,0 +1,28 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Turtles Mob", function ()
describe("Turtles", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_turtles:turtle", { "default:dirt_with_grass", "default:jungle_grass", "default:sand", "default:desert_sand" }, { "default:dirt_with_grass", "default:jungle_grass", "default:sand", "default:desert_sand", "default:papyrus", "default:cactus", "dryplants:juncus", "dryplants:reedmace" }, 5, 20, 30, 300000, 1, 1, 5000)
stub_spawn_specific.called_with(mobs, "mobs_turtles:seaturtle", { "default:water_flowing", "default:water_source" }, { "default:water_flowing", "default:water_source", "group:seaplants", "seawrecks:woodship", "seawrecks:uboot" }, 5, 20, 30, 300000, 1, -50, 0)
end)
end)
end)
test.execute(true)

View File

@ -1,3 +1,4 @@
default
mobs
mobs_fish?
test?

View File

@ -103,3 +103,6 @@ end
mobs:register_egg("mobs_walrus:walrus", "Walrus", "default_grass.png", 1)
minetest.register_alias_force("arctic_life:walrus", "mobs_walrus:walrus")
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_walrus/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Walrus Mob", function ()
describe("Walrus", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_walrus:walrus", { "default:dirt_with_snow", "default:snowblock", "default:ice" }, { "air" }, 0, 20, 30, 300000, 1, -31000, 5000)
end)
end)
end)
test.execute(true)

View File

@ -1,2 +1,3 @@
default
mobs
test?

View File

@ -15,7 +15,7 @@ local mod_config = config.settings_model('mobs_wolf', {
chance = config.types.int(300000, { min=1 }),
min_light = config.types.int(10, { min=0 }),
max_light = config.types.int(15, { min=0 }),
min_height = config.types.int(-5, { min=-31000, max=31000 }),
min_height = config.types.int(-4, { min=-31000, max=31000 }),
max_height = config.types.int(5000, { min=-31000, max=31000 }),
active_object_count = config.types.int(1, { min=1 }),
}
@ -172,3 +172,6 @@ mobs:register_mob("mobs_wolf:dog", {
})
mobs:register_egg("mobs_wolf:dog", "Dog", "wool_brown.png", 1)
dofile(minetest.get_modpath(minetest.get_current_modname())..'/test.lua')

27
mobs_wolf/test.lua Normal file
View File

@ -0,0 +1,27 @@
if not minetest.global_exists('test') then return end
if test.active then return end
local describe = test.describe
local it = test.it
local stub = test.stub
local assert_equal = test.assert.equal
describe("Wolf Mob", function ()
describe("Wolf", function ()
local original_spawn_specific = mobs.spawn_specific
local stub_spawn_specific = stub()
test.before_all(function ()
mobs.spawn_specific = stub_spawn_specific.call
end)
test.after_all(function ()
mobs.spawn_specific = original_spawn_specific
end)
it("calls the main mob spawn registration function with the same values as before config was added", function ()
dofile(minetest.get_modpath(minetest.get_current_modname()) .. "/init.lua")
-- The original call before config was added, testing for consistency with config defaults
stub_spawn_specific.called_with(mobs, "mobs_wolf:wolf", { "default:dirt_with_grass", "default:dirt_with_snow", "default:dirt_with_coniferous_litter", "ethereal:green_dirt_top" }, { "air" }, 10, 15, 30, 300000, 1, -4, 5000, true)
end)
end)
end)
test.execute(true)