Tone.js/test/helper/ConstantOutput.ts

14 lines
401 B
TypeScript
Raw Normal View History

2019-04-12 14:37:47 +00:00
import { expect } from "chai";
import { Offline } from "./Offline";
/**
* Test that the output of the callback is a constant value
*/
export async function ConstantOutput(
callback: (context: BaseAudioContext) => Promise<void> | void,
value: number, threshold = 0.01,
): Promise<void> {
const buffer = await Offline(callback, 0.01, 1);
expect(buffer.value()).to.be.closeTo(value, threshold);
}