From 7579400439567f24336be3605e5ef07b8f55a9e7 Mon Sep 17 00:00:00 2001 From: Divyanshu Raj Date: Sat, 9 May 2020 09:18:52 +0530 Subject: [PATCH] added tests for addCue callbacks --- test/tests/p5.SoundFile.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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); + + }) }); });