avocado/packages/timing/test/lfo.js
2022-03-27 02:33:55 -05:00

26 lines
553 B
JavaScript

import {expect} from 'chai';
import LfoResult from '../src/lfo/result';
it('can do linear oscillation', () => {
const object = {x: 0};
const result = new LfoResult(
object,
{
x: {
frequency: 1,
magnitude: 100,
median: 50,
},
},
);
result.tick(0.1);
expect(object.x).to.be.closeTo(70, 0.001);
result.tick(0.5);
expect(object.x).to.be.closeTo(30, 0.001);
result.tick(0.25);
expect(object.x).to.be.closeTo(20, 0.001);
result.tick(0.4);
expect(object.x).to.be.closeTo(100, 0.001);
});