local I=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local A=require(I.Packages.Dex.Observables.Spring)local f=require(I.Packages.Dex.Observables.State)return function()it("\115\104\111\117\108\100 \099\114\101\097\116\101 \097 \083\112\114\105\110\103 \119\104\105\099\104 \101\097\115\101\115 \116\111\119\097\114\100\115 \116\097\114\103\101\116",function()local I=f.new(0)local T=A.new(I)local function W()local I=os.clock()while os.clock()==I do end end;(expect(T)).to.be.ok()I:Set(1)W();(expect(T:Current()<.1)).to.be.equal(true);(expect(T:Current())).to.never.be.equal(0)I:Set(.5)W();(expect(T:Current()<.1)).to.be.equal(true);(expect(T:Current())).to.never.be.equal(0)T:ResetVelocity()I:Set(-100)local J=T:Current()W();(expect(T:Current()<J)).to.be.equal(true)end)it("\115\104\111\117\108\100 \116\104\114\111\119 \097\110 \101\114\114\111\114 \102\111\114 \117\110\115\117\112\112\111\114\116\101\100 \100\097\116\097 \116\121\112\101\115",function()local I=f.new(true);(expect(function()A.new(I)end)).to.throw("\068\097\116\097 \116\121\112\101 \'\098\111\111\108\101\097\110\' \099\097\110\110\111\116 \098\101 \101\097\115\101\100 \117\115\105\110\103 \083\112\114\105\110\103")end)end
--!strict
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Spring = require(ReplicatedStorage.Packages.Dex.Observables.Spring)
local State = require(ReplicatedStorage.Packages.Dex.Observables.State)
return function()
    it("should create a Spring which eases towards target", function()
        local target = State.new(0)
        local easingObservable = Spring.new(target)

        local function waitUntilClockChange()
            local start = os.clock()
            -- selene: allow(empty_loop)
            while os.clock() == start do end
        end

        expect(easingObservable).to.be.ok()
        target:Set(1)
        waitUntilClockChange()
        expect(easingObservable:Current() < 0.1).to.be.equal(true)
        expect(easingObservable:Current()).to.never.be.equal(0)
        target:Set(0.5)
        waitUntilClockChange()
        expect(easingObservable:Current() < 0.1).to.be.equal(true)
        expect(easingObservable:Current()).to.never.be.equal(0)
        easingObservable:ResetVelocity()
        target:Set(-100)
        local highestPoint = easingObservable:Current()
        waitUntilClockChange()
        expect(easingObservable:Current() < highestPoint).to.be.equal(true)
    end)
    
    it("should throw an error for unsupported data types", function()
        local target = State.new(true)
        expect(function()
            Spring.new(target)
        end).to.throw("Data type 'boolean' cannot be eased using Spring")
    end)
end
