UNPKG

1.22 kBPlain TextView Raw
1import { Chebyshev } from "./Chebyshev.js";
2import { BasicTests } from "../../test/helper/Basic.js";
3import { EffectTests } from "../../test/helper/EffectTests.js";
4import { expect } from "chai";
5import { CompareToFile } from "../../test/helper/CompareToFile.js";
6import { Synth } from "../instrument/index.js";
7
8describe("Chebyshev", () => {
9 BasicTests(Chebyshev);
10 EffectTests(Chebyshev, 51);
11
12 it("matches a file", () => {
13 return CompareToFile(
14 () => {
15 const cheby = new Chebyshev(100).toDestination();
16 const synth = new Synth().connect(cheby);
17 synth.triggerAttackRelease("C2", 0.2);
18 },
19 "chebyshev.wav",
20 0.01
21 );
22 });
23
24 context("API", () => {
25 it("can pass in options in the constructor", () => {
26 const cheby = new Chebyshev({
27 order: 2,
28 });
29 expect(cheby.order).to.equal(2);
30 cheby.dispose();
31 });
32
33 it("can get/set the options", () => {
34 const cheby = new Chebyshev();
35 cheby.set({
36 order: 40,
37 });
38 expect(cheby.get().order).to.equal(40);
39 cheby.dispose();
40 });
41
42 it("throws an error if order is not an integer", () => {
43 const cheby = new Chebyshev();
44 expect(() => {
45 cheby.order = 0.2;
46 }).to.throw(Error);
47 cheby.dispose();
48 });
49 });
50});