Skip to content

Commit

Permalink
added tests for addCue callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
endurance21 committed May 9, 2020
1 parent 97fe871 commit 7579400
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/tests/p5.SoundFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

})

});
});

0 comments on commit 7579400

Please sign in to comment.