1 | import { ConstantOutput } from "../../test/helper/ConstantOutput.js";
|
2 | import { ScaleExp } from "./ScaleExp.js";
|
3 | import { BasicTests } from "../../test/helper/Basic.js";
|
4 | import { Signal } from "./Signal.js";
|
5 | import { expect } from "chai";
|
6 |
|
7 | describe("ScaleExp", () => {
|
8 | BasicTests(ScaleExp);
|
9 |
|
10 | context("Scaling", () => {
|
11 | it("can set the min and max values", () => {
|
12 | const scale = new ScaleExp(-20, 10, 2);
|
13 | scale.min = -0.01;
|
14 | expect(scale.min).to.be.closeTo(-0.01, 0.001);
|
15 | scale.max = 1000;
|
16 | expect(scale.max).to.be.closeTo(1000, 0.001);
|
17 | scale.dispose();
|
18 | });
|
19 |
|
20 | it("can set the exponent value", () => {
|
21 | const scale = new ScaleExp(0, 100, 2);
|
22 | expect(scale.exponent).to.be.closeTo(2, 0.001);
|
23 | scale.exponent = 3;
|
24 | expect(scale.exponent).to.be.closeTo(3, 0.001);
|
25 | scale.dispose();
|
26 | });
|
27 |
|
28 | it("scales a signal between two values exponentially", () => {
|
29 | return ConstantOutput(() => {
|
30 | const signal = new Signal(0.5);
|
31 | const scale = new ScaleExp(0, 1, 3);
|
32 | signal.connect(scale);
|
33 | scale.toDestination();
|
34 | }, 0.125);
|
35 | });
|
36 |
|
37 | it("scale a signal between 1 and 3 exponentially", () => {
|
38 | return ConstantOutput(() => {
|
39 | const signal = new Signal(0.5);
|
40 | const scale = new ScaleExp(1, 3, 2);
|
41 | signal.connect(scale);
|
42 | scale.toDestination();
|
43 | }, 1.5);
|
44 | });
|
45 | });
|
46 | });
|