diff --git a/test/tests/p5.SoundFile.js b/test/tests/p5.SoundFile.js index aea38d3f..c3c0941d 100644 --- a/test/tests/p5.SoundFile.js +++ b/test/tests/p5.SoundFile.js @@ -115,6 +115,30 @@ define(['chai'], function(chai) { done(); }, 100); }); + it('calls the cueCallbacks correct number of times', function(done){ + this.timeout(2000); + const onloaded = ()=>{ + let audioLength = sf.duration(); + let numberOfCuesCalls = 0 ; + + let callback = ()=>{ numberOfCuesCalls++;} ; + + sf.addCue(audioLength/5,callback); + sf.addCue(audioLength*2/5,callback); + sf.addCue(audioLength*3/5,callback); + sf.addCue(audioLength*4/5,callback); + + sf.play(); + + sf.onended(()=>{ + expect(numberOfCuesCalls).to.equal(4); + done(); + }); + } + + let sf = new p5.SoundFile('./testAudio/drum', onloaded); + + }) }); });