Skip to content

Commit 1b60962

Browse files
(Gsoc'21)🔨Corrects broken tests part-2
1 parent 54c4566 commit 1b60962

File tree

6 files changed

+22
-16
lines changed

6 files changed

+22
-16
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
},
3636
"parserOptions": {
37-
"ecmaVersion": 6,
37+
"ecmaVersion": 8,
3838
"sourceType": "module",
3939
"allowImportExportEverywhere": true
4040
}

lib/p5.sound.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** [p5.sound] Version: 1.0.1 - 2021-06-10 */
1+
/** [p5.sound] Version: 1.0.1 - 2021-06-11 */
22
/**
33
* <p>p5.sound extends p5 with <a href="http://caniuse.com/audio-api"
44
* target="_blank">Web Audio</a> functionality including audio input,

lib/p5.sound.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/tests/p5.Helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ describe('Testing helpers function', function () {
88

99
it('p5.prototype.midiToFreq helper function', function () {
1010
const freq = p5.prototype.midiToFreq(100);
11-
expect(freq).to.equal(2637.0204553029594);
11+
expect(freq).to.be.approximately(2637.0204553029594, 0.00000000001);
1212
});
1313

1414
it('p5.prototype.noteToFreq helper function', function () {
1515
const freq = p5.prototype.noteToFreq('C4');
16-
expect(freq).to.equal(261.6255653005986);
16+
expect(freq).to.be.approximately(261.6255653005986, 0.00000000001);
1717
});
1818

1919
it('p5.prototype.soundFormats helper function', function () {

test/tests/p5.MonoSynth.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ describe('p5.MonoSynth', function () {
1515
expect(monoSynth.oscillator.freq().value).to.equal(110);
1616
monoSynth.dispose();
1717
done();
18-
}, 1);
18+
}, 10);
1919
});
2020
});

test/tests/p5.PolySynth.js

Lines changed: 16 additions & 10 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', function () {
11+
it('keeps track of the number of voicesInUse', async function () {
1212
const polySynth = new p5.PolySynth();
1313
const noteDuration = 0.01;
1414

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

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

21-
polySynth.play('A2', 0, 0, noteDuration);
21+
await polySynth.play('A2', 0, 0, noteDuration);
2222
expect(polySynth._voicesInUse.getValueAtTime(noteActiveTime)).to.equal(1);
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-
expect(polySynth._voicesInUse.getValueAtTime(noteDoneTime)).to.equal(0);
29-
30-
polySynth.dispose();
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();
3137
});
3238
});

0 commit comments

Comments
 (0)