print(package.path)

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

_G.defense_mob_api = {library = {}}

require("timer_api")



describe("timer_api", function()
		local entity = {timers = {}}
		local callback_called = 0
		defense_mob_api.library.set_up_timer(entity,
			10,
			function(self, elapsed)
				callback_called = callback_called + 1
			end,
			"test_timer")
		
		it("initializes", function()
				assert(entity.timers[#entity.timers])
				assert.equals(entity.timers[#entity.timers], entity.timers.test_timer)
			end)
		
		
		it("manipulates", function()
				entity.timers.test_timer.manipulate_time(entity, 1)
				assert.equals(9, entity.timers.test_timer.get_remaining_time())
			end)
		it("refreshes", function()
				defense_mob_api.library.set_up_timer(entity,
					1,
					function(self, elapsed)
						callback_called = callback_called + 1
					end,
					"test_timer")
			end)
		
		it("calls callbacks", function()
				entity.timers.test_timer.manipulate_time(entity,
					entity.timers.test_timer.get_remaining_time())
				assert.equals(1, callback_called)
			end)
		it("deletes itself", function()
				assert.equals(nil, entity.timers[#entity.timers])
				assert.equals(nil, entity.timers.test_timer)
			end)
	end)
