Skip to content

Commit 4577368

Browse files
(Gsoc'21)🔨Corrects broken tests part-4
1 parent 04265ea commit 4577368

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

test/tests/p5.PolySynth.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,20 @@ describe('p5.PolySynth', function () {
1212
const polySynth = new p5.PolySynth();
1313
const noteDuration = 0.01;
1414

15-
const noteTriggerTime = audioContext.currentTime;
16-
const noteActiveTime = noteTriggerTime + noteDuration / 2;
17-
const noteDoneTime = noteTriggerTime + noteDuration;
15+
const getTriggerTime = () => audioContext.currentTime;
16+
const getActiveTime = () => getTriggerTime() + noteDuration / 2;
17+
const getDoneTime = () => getTriggerTime() + noteDuration;
1818

19-
expect(polySynth._voicesInUse.getValueAtTime(noteTriggerTime)).to.equal(0);
19+
expect(polySynth._voicesInUse.getValueAtTime(getTriggerTime())).to.equal(0);
2020

2121
polySynth.play('A2', 0, 0, noteDuration);
22-
expect(polySynth._voicesInUse.getValueAtTime(noteActiveTime)).to.equal(1);
22+
expect(polySynth._voicesInUse.getValueAtTime(getActiveTime())).to.equal(1);
2323
polySynth.play('A3', 0, 0, noteDuration);
24-
expect(polySynth._voicesInUse.getValueAtTime(noteActiveTime)).to.equal(2);
24+
expect(polySynth._voicesInUse.getValueAtTime(getActiveTime())).to.equal(2);
2525
polySynth.play('A4', 0, 0, noteDuration);
26-
expect(polySynth._voicesInUse.getValueAtTime(noteActiveTime)).to.equal(3);
26+
expect(polySynth._voicesInUse.getValueAtTime(getActiveTime())).to.equal(3);
2727

28-
setTimeout(() => {
29-
expect(polySynth._voicesInUse.getValueAtTime(noteDoneTime)).to.equal(0);
30-
}, 10);
28+
expect(polySynth._voicesInUse.getValueAtTime(getDoneTime())).to.equal(0);
3129

3230
polySynth.dispose();
3331
});

0 commit comments

Comments
 (0)