local I=script.Parent.Parent.Parent local p=require(I.LuauPolyfill)local l=p.Array local t=require(I.Dev.JestGlobals)local o=t.expect local b=t.describe local q=t.it local Y=require(script.Parent.Parent.calculateStats)b("\099\097\108\099\117\108\097\116\101\083\116\097\116\115",function()q("\115\104\111\117\108\100 \099\097\108\099\117\108\097\116\101 \101\109\112\116\121 \115\116\097\116\115",function()(o(Y({}))).toEqual({min=math.huge;max=-math.huge;mean=0;variance=0;stdDev=0;count=0})end)q("\115\104\111\117\108\100 \099\097\108\099\117\108\097\116\101 \111\110\101 \101\108\101\109\101\110\116 \115\116\097\116\115",function()l.map({0;1,10,50},function(I)(o(Y({I}))).toEqual({min=I,max=I,mean=I,variance=0,stdDev=0,count=1})end)end)q("\115\104\111\117\108\100 \099\097\108\099\117\108\097\116\101 \109\117\108\116\105\112\108\101 \115\097\109\101 \101\108\101\109\101\110\116\115 \101\108\101\109\101\110\116 \115\116\097\116\115",function()l.map({0,1;10,50},function(I)(o(Y({I,I;I}))).toEqual({min=I;max=I,mean=I;variance=0,stdDev=0;count=3})end)end)q("\115\104\111\117\108\100 \099\097\108\099\117\108\097\116\101 \115\116\097\116\115 \102\111\114 \123\049\044 \050\044 \051\125",function()(o(Y({1,2;3}))).toEqual({min=1,max=3;mean=2;variance=1;stdDev=1;count=3})end)q("\115\104\111\117\108\100 \099\097\108\099\117\108\097\116\101 \115\116\097\116\115 \123\049\046\046\052\056\125",function()local I={}for p=1,48,1 do table.insert(I,p)end;(o(Y(I))).toEqual({min=1;max=48;mean=24.5;variance=196,stdDev=14,count=48})end)end)
local rootWorkspace = script.Parent.Parent.Parent

local LuauPolyfill = require(rootWorkspace.LuauPolyfill)
local Array = LuauPolyfill.Array

local JestGlobals = require(rootWorkspace.Dev.JestGlobals)
local jestExpect = JestGlobals.expect
local describe = JestGlobals.describe
local it = JestGlobals.it

local calculateStats = require(script.Parent.Parent.calculateStats)

describe("calculateStats", function()
	it("should calculate empty stats", function()
		jestExpect(calculateStats({})).toEqual({
			min = math.huge,
			max = -math.huge,
			mean = 0,
			variance = 0,
			stdDev = 0,
			count = 0,
		})
	end)

	it("should calculate one element stats", function()
		Array.map({ 0, 1, 10, 50 }, function(v)
			jestExpect(calculateStats({ v })).toEqual({
				min = v,
				max = v,
				mean = v,
				variance = 0,
				stdDev = 0,
				count = 1,
			})
		end)
	end)

	it("should calculate multiple same elements element stats", function()
		Array.map({ 0, 1, 10, 50 }, function(v)
			jestExpect(calculateStats({ v, v, v })).toEqual({
				min = v,
				max = v,
				mean = v,
				variance = 0,
				stdDev = 0,
				count = 3,
			})
		end)
	end)

	it("should calculate stats for {1, 2, 3}", function()
		jestExpect(calculateStats({ 1, 2, 3 })).toEqual({
			min = 1,
			max = 3,
			mean = 2,
			variance = 1,
			stdDev = 1,
			count = 3,
		})
	end)

	it("should calculate stats {1..48}", function()
		local data = {}
		for i = 1, 48 do
			table.insert(data, i)
		end
		jestExpect(calculateStats(data)).toEqual({
			min = 1,
			max = 48,
			mean = 24.5,
			variance = 196,
			stdDev = 14,
			count = 48,
		})
	end)
end)
