local h=(game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")):WaitForChild("\078\101\120\117\115\082\101\112\108\105\099\097\116\105\111\110")local i=require((h:WaitForChild("\069\120\097\109\112\108\101")):WaitForChild("\084\105\109\101\114"))return function()local h=nil beforeEach(function()h=i.new()end)afterEach(function()h:Destroy()end)describe("\065 \116\105\109\101\114 \105\110\115\116\097\110\099\101",function()it("\115\104\111\117\108\100 \115\116\097\114\116\046",function()h:SetDuration(.2);(expect(h.State)).to.equal("\083\084\079\080\080\069\068");(expect(h:GetRemainingTime())).to.be.near(.2,.025)h:Start();(expect(h.State)).to.equal("\065\067\084\073\086\069");(expect(h:GetRemainingTime())).to.be.near(.2,.025)task.wait(.1);(expect(h.State)).to.equal("\065\067\084\073\086\069");(expect(h:GetRemainingTime())).to.be.near(.1,.025)h:Start()task.wait(.15);(expect(h.State)).to.equal("\067\079\077\080\076\069\084\069");(expect(h:GetRemainingTime())).to.be.near(0,.025)h:Start();(expect(h.State)).to.equal("\067\079\077\080\076\069\084\069")end)it("\115\104\111\117\108\100 \115\116\111\112\046",function()h:SetDuration(.2);(expect(h.State)).to.equal("\083\084\079\080\080\069\068");(expect(h:GetRemainingTime())).to.be.near(.2,.025)h:Start();(expect(h.State)).to.equal("\065\067\084\073\086\069");(expect(h:GetRemainingTime())).to.be.near(.2,.025)task.wait(.1)h:Stop();(expect(h.State)).to.equal("\083\084\079\080\080\069\068");(expect(h:GetRemainingTime())).to.be.near(.1,.025)task.wait(.1)h:Start();(expect(h.State)).to.equal("\065\067\084\073\086\069");(expect(h:GetRemainingTime())).to.be.near(.1,.025)task.wait(.05);(expect(h.State)).to.equal("\065\067\084\073\086\069");(expect(h:GetRemainingTime())).to.be.near(.05,.025)task.wait(.1);(expect(h.State)).to.equal("\067\079\077\080\076\069\084\069");(expect(h:GetRemainingTime())).to.be.near(0,.025)h:Start();(expect(h.State)).to.equal("\067\079\077\080\076\069\084\069")h:Stop();(expect(h.State)).to.equal("\067\079\077\080\076\069\084\069");(expect(h:GetRemainingTime())).to.be.near(0,.025)end)it("\115\104\111\117\108\100 \099\111\109\112\108\101\116\101\046",function()h:SetDuration(.2);(expect(h.State)).to.equal("\083\084\079\080\080\069\068")h:Start()task.wait(.1)h:Complete();(expect(h.State)).to.equal("\067\079\077\080\076\069\084\069");(expect(h:GetRemainingTime())).to.be.near(0,.025)task.wait(.15);(expect(h.State)).to.equal("\067\079\077\080\076\069\084\069");(expect(h:GetRemainingTime())).to.be.near(0,.025)end)end)end
--Tests the Timer class.
--!strict

local NexusReplicationModule = game:GetService("ReplicatedStorage"):WaitForChild("NexusReplication")

local Timer = require(NexusReplicationModule:WaitForChild("Example"):WaitForChild("Timer"))

return function()
    local TestTimer = nil
    beforeEach(function()
        TestTimer = Timer.new()
    end)
    afterEach(function()
        TestTimer:Destroy()
    end)

    describe("A timer instance", function()
        it("should start.", function()
            TestTimer:SetDuration(0.2)
            expect(TestTimer.State).to.equal("STOPPED")
            expect(TestTimer:GetRemainingTime()).to.be.near(0.2, 0.025)
            TestTimer:Start()
            expect(TestTimer.State).to.equal("ACTIVE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0.2, 0.025)
            task.wait(0.1)
            expect(TestTimer.State).to.equal("ACTIVE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0.1, 0.025)
            TestTimer:Start()
            task.wait(0.15)
            expect(TestTimer.State).to.equal("COMPLETE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0, 0.025)
            TestTimer:Start()
            expect(TestTimer.State).to.equal("COMPLETE")
        end)

        it("should stop.", function()
            TestTimer:SetDuration(0.2)
            expect(TestTimer.State).to.equal("STOPPED")
            expect(TestTimer:GetRemainingTime()).to.be.near(0.2, 0.025)
            TestTimer:Start()
            expect(TestTimer.State).to.equal("ACTIVE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0.2, 0.025)
            task.wait(0.1)
            TestTimer:Stop()
            expect(TestTimer.State).to.equal("STOPPED")
            expect(TestTimer:GetRemainingTime()).to.be.near(0.1, 0.025)
            task.wait(0.1)
            TestTimer:Start()
            expect(TestTimer.State).to.equal("ACTIVE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0.1, 0.025)
            task.wait(0.05)
            expect(TestTimer.State).to.equal("ACTIVE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0.05, 0.025)
            task.wait(0.1)
            expect(TestTimer.State).to.equal("COMPLETE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0, 0.025)
            TestTimer:Start()
            expect(TestTimer.State).to.equal("COMPLETE")
            TestTimer:Stop()
            expect(TestTimer.State).to.equal("COMPLETE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0, 0.025)
        end)

        it("should complete.", function()
            TestTimer:SetDuration(0.2)
            expect(TestTimer.State).to.equal("STOPPED")
            TestTimer:Start()
            task.wait(0.1)
            TestTimer:Complete()
            expect(TestTimer.State).to.equal("COMPLETE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0, 0.025)
            task.wait(0.15)
            expect(TestTimer.State).to.equal("COMPLETE")
            expect(TestTimer:GetRemainingTime()).to.be.near(0, 0.025)
        end)
    end)
end