local b=import("\046\047\072\117\109\097\110\111\105\100")local t=import("\046\046\047\073\110\115\116\097\110\099\101")local A=import("\046\047\087\111\114\107\115\112\097\099\101")describe("\105\110\115\116\097\110\099\101\115\046\072\117\109\097\110\111\105\100",function()it("\115\104\111\117\108\100 \105\110\115\116\097\110\116\105\097\116\101",function()local b=t.new("\072\117\109\097\110\111\105\100")assert.not_nil(b)assert.equal(b.Health,100)assert.equal(b.MaxHealth,100)end)it("\115\104\111\117\108\100 \099\108\097\109\112 \104\101\097\108\116\104 \097\110\100 \109\097\120 \104\101\097\108\116\104",function()local t=b:new()t.MaxHealth=50 assert.equal(t.MaxHealth,50)assert.equal(t.Health,50)t.MaxHealth=100 assert.equal(t.MaxHealth,100)assert.equal(t.Health,50)t.Health=300 assert.equal(t.MaxHealth,100)assert.equal(t.Health,100)t.Health=-10 assert.equal(t.Health,0)t.MaxHealth=-10 assert.equal(t.MaxHealth,0)assert.equal(t.Health,0)end)it("\115\104\111\117\108\100 \099\097\108\108 \068\105\101\100 \119\104\101\110 \072\101\097\108\116\104 \105\115 \115\101\116 \116\111 \048 \097\110\100 \116\104\101 \072\117\109\097\110\111\105\100 \105\115 \105\110 \087\111\114\107\115\112\097\099\101",function()local t=b:new()local H=spy.new(function() end)t.Died:Connect(H)t.Health=0;(assert.spy(H)).was_called(0)t.Health=100;(assert.spy(H)).was_called(0)t.Parent=A:new();(assert.spy(H)).was_called(0)t.Health=0;(assert.spy(H)).was_called(1)end)end)
local Humanoid = import("./Humanoid")
local Instance = import("../Instance")
local Workspace = import("./Workspace")

describe("instances.Humanoid", function()
	it("should instantiate", function()
		local instance = Instance.new("Humanoid")

		assert.not_nil(instance)
		assert.equal(instance.Health, 100)
		assert.equal(instance.MaxHealth, 100)
	end)

	it("should clamp health and max health", function()
		local instance = Humanoid:new()

		instance.MaxHealth = 50
		assert.equal(instance.MaxHealth, 50)
		assert.equal(instance.Health, 50)

		instance.MaxHealth = 100
		assert.equal(instance.MaxHealth, 100)
		assert.equal(instance.Health, 50)

		instance.Health = 300
		assert.equal(instance.MaxHealth, 100)
		assert.equal(instance.Health, 100)

		instance.Health = -10
		assert.equal(instance.Health, 0)

		instance.MaxHealth = -10
		assert.equal(instance.MaxHealth, 0)
		assert.equal(instance.Health, 0)
	end)

	it("should call Died when Health is set to 0 and the Humanoid is in Workspace", function()
		local instance = Humanoid:new()

		local spy = spy.new(function() end)
		instance.Died:Connect(spy)
		instance.Health = 0
		assert.spy(spy).was_called(0)
		instance.Health = 100
		assert.spy(spy).was_called(0)

		instance.Parent = Workspace:new()
		assert.spy(spy).was_called(0)
		instance.Health = 0
		assert.spy(spy).was_called(1)
	end)
end)
