print(package.path)

package.path = "../?.lua;" .. package.path

_G.defense_mob_api = {library = {}}

require("set_animation")



describe("set_animation", function()
		local set_animation = 0
		
		local entity =
		{
			timer = 0,
			
			object =
			{
				set_animation = function()
					set_animation = set_animation + 1
				end
			},
			animation =
			{
				walk =
				{
					rate = 30,
					a = 10,
					b = 20,
				},
				swim =
				{
					rate = 30,
					a = 10,
					b = 20,
				}
			}
		}
		
		defense_mob_api.library.set_animation(entity, "walk")
		it("sets animations on the object", function()
				assert.equals(1, set_animation)
			end)
		it("sets animation stuff on the luaentity", function()
				assert.equals("walk", entity.current_animation)
				assert.equals(9 / 30, entity.current_animation_end)
			end)
		it("does nothing for unknown animations", function()
				defense_mob_api.library.set_animation(entity, "unknown")
				assert.equals(1, set_animation)
			end)
		it("inhibits", function()
				defense_mob_api.library.set_animation(entity, "swim", {"walk"})
				assert.equals(1, set_animation)
			end)
			
		it("doesn't inhibit when time is up", function()
				entity.timer = 10
				defense_mob_api.library.set_animation(entity, "swim", {"walk"})
				assert.equals(2, set_animation)
			end)
	end)
