InGameAvatarEditor/src/ServerScriptService/AvatarEditorInGameSetup/AvatarEditorInGame/Modules/Packages/Cryo/List/foldLeft.spec.lua
return function()
	local foldLeft = require(script.Parent.foldLeft)

	it("should call the callback", function()
		local a = {1, 2, 3}
		local called = 0

		foldLeft(a, function()
			called = called + 1
		end, 0)

		expect(called).to.equal(3)
	end)

	it("should not call the callback when the list is empty", function()
		local called = false

		foldLeft({}, function()
			called = true
		end, 0)

		expect(called).to.equal(false)
	end)

	it("should call the callback for each element", function()
		local a = {4, 5, 6}
		local copy = {}

		foldLeft(a, function(accum, value, index)
			copy[index] = value
			return accum
		end, 0)

		expect(#copy).to.equal(#a)

		for key, value in pairs(a) do
			expect(value).to.equal(copy[key])
		end
	end)

	it("should pass the same modified initial value to the callback", function()
		local a = {5, 4, 3}
		local initialValue = {}

		foldLeft(a, function(accum)
			expect(accum).to.equal(initialValue)
			return accum
		end, initialValue)
	end)

	it("should call the callback in the correct order", function()
		local a = {5, 4, 3}
		local index = 1

		foldLeft(a, function(accum, value)
			expect(value).to.equal(a[index])
			index = index + 1
			return accum
		end, 0)
	end)
end