Skip to content

Commit 04265ea

Browse files
(Gsoc'21)🔨Corrects broken tests part-3
1 parent 6f2d824 commit 04265ea

File tree

2 files changed

+17
-20
lines changed

2 files changed

+17
-20
lines changed

test/tests/p5.PolySynth.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ describe('p5.PolySynth', function () {
88
polySynth.dispose();
99
});
1010

11-
it('keeps track of the number of voicesInUse', async function () {
11+
it('keeps track of the number of voicesInUse', function () {
1212
const polySynth = new p5.PolySynth();
1313
const noteDuration = 0.01;
1414

@@ -18,21 +18,17 @@ describe('p5.PolySynth', function () {
1818

1919
expect(polySynth._voicesInUse.getValueAtTime(noteTriggerTime)).to.equal(0);
2020

21-
await polySynth.play('A2', 0, 0, noteDuration);
21+
polySynth.play('A2', 0, 0, noteDuration);
2222
expect(polySynth._voicesInUse.getValueAtTime(noteActiveTime)).to.equal(1);
23-
await polySynth.play('A3', 0, 0, noteDuration);
24-
expect(
25-
await polySynth._voicesInUse.getValueAtTime(noteActiveTime)
26-
).to.equal(2);
27-
await polySynth.play('A4', 0, 0, noteDuration);
28-
expect(
29-
await polySynth._voicesInUse.getValueAtTime(noteActiveTime)
30-
).to.equal(3);
31-
32-
expect(await polySynth._voicesInUse.getValueAtTime(noteDoneTime)).to.equal(
33-
0
34-
);
35-
36-
await polySynth.dispose();
23+
polySynth.play('A3', 0, 0, noteDuration);
24+
expect(polySynth._voicesInUse.getValueAtTime(noteActiveTime)).to.equal(2);
25+
polySynth.play('A4', 0, 0, noteDuration);
26+
expect(polySynth._voicesInUse.getValueAtTime(noteActiveTime)).to.equal(3);
27+
28+
setTimeout(() => {
29+
expect(polySynth._voicesInUse.getValueAtTime(noteDoneTime)).to.equal(0);
30+
}, 10);
31+
32+
polySynth.dispose();
3733
});
3834
});

test/tests/p5.SoundRecorder.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe('p5.SoundRecorder', function () {
6767
p5.prototype.outputVolume(0);
6868
done();
6969
});
70-
}, 100);
70+
}, 130);
7171
});
7272
});
7373

@@ -77,8 +77,9 @@ describe('p5.SoundRecorder', function () {
7777
const recordingDuration =
7878
recorder.bufferSize / p5.soundOut.audiocontext.sampleRate;
7979
const inputChannel = inputSoundFile.buffer.getChannelData(0);
80+
const inputChannelSampleValue = inputChannel[sampleIndex];
8081
// input SoundFile should contain all 1s
81-
expect(inputChannel[sampleIndex]).to.eq(1);
82+
expect(inputChannelSampleValue).to.eq(1);
8283

8384
const outputSoundFile = new p5.SoundFile();
8485
inputSoundFile.loop();
@@ -87,7 +88,7 @@ describe('p5.SoundRecorder', function () {
8788
expect(outputSoundFile.duration()).to.eq(recordingDuration);
8889

8990
var outputChannel = outputSoundFile.buffer.getChannelData(0);
90-
expect(outputChannel[sampleIndex]).to.eq(inputChannel[sampleIndex]);
91+
expect(outputChannel[sampleIndex]).to.eq(inputChannelSampleValue);
9192

9293
outputSoundFile.dispose();
9394
done();
@@ -120,7 +121,7 @@ describe('p5.SoundRecorder', function () {
120121
p5.prototype.outputVolume(0);
121122
done();
122123
});
123-
}, 10);
124+
}, 20);
124125
});
125126

126127
it('can save a recorded buffer to a .wav file', function (done) {

0 commit comments

Comments
 (0)