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