Skip to content

Commit ed98f4c

Browse files
(Gsoc'21)➕Added tests for monsetDetect,peakDetect
1 parent 329ad99 commit ed98f4c

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

test/tests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import('./tests/main.js');
22
import('./tests/p5.Helpers.js');
3+
import('./tests/p5.PeakDetect.js')
4+
import('./tests/p5.OnsetDetect.js')
35
import('./tests/p5.Distortion.js');
46
import('./tests/p5.AudioContext.js');
57
import('./tests/p5.Metro.js')

test/tests/p5.OnsetDetect.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const expect = chai.expect;
2+
3+
describe('p5.OnsetDetect', function () {
4+
it('can be initalized ', function () {
5+
const onsetDetect = new p5.OnsetDetect(40, 120, 0.8, () => {});
6+
expect(onsetDetect.freqLow).to.equal(40);
7+
expect(onsetDetect.freqHigh).to.equal(120);
8+
expect(onsetDetect.treshold).to.equal(0.8);
9+
expect(onsetDetect.energy).to.equal(0);
10+
});
11+
12+
describe('methods', function () {
13+
//TODO : test update functions by mocking or using a FFT
14+
});
15+
});

test/tests/p5.PeakDetect.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const expect = chai.expect;
2+
3+
describe('p5.PeakDetect', function () {
4+
it('can be initalized without any arguemts', function () {
5+
const peakDetect = new p5.PeakDetect();
6+
expect(peakDetect.cutoff).to.equal(0);
7+
expect(peakDetect.framesSinceLastPeak).to.equal(0);
8+
expect(peakDetect.energy).to.equal(0);
9+
expect(peakDetect.isDetected).to.equal(false);
10+
});
11+
it('can be initalized with arguemts', function () {
12+
const peakDetect = new p5.PeakDetect(40, 120, 0.8, 20);
13+
expect(peakDetect.f1).to.equal(40);
14+
expect(peakDetect.f2).to.equal(120);
15+
expect(peakDetect.threshold).to.equal(0.8);
16+
expect(peakDetect.framesPerPeak).to.equal(20);
17+
});
18+
describe('methods', function () {
19+
//TODO : test update, onPeak functions by mocking or using a FFT
20+
});
21+
});

0 commit comments

Comments
 (0)