123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- import WaveSurfer from '../src/wavesurfer.js';
- /** @test {WaveSurfer} */
- describe('WaveSurfer/playback:', function () {
- var wavesurfer;
- jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
- /*
- * Handle creating wavesurfer ui requirements
- */
- function __createWaveform() {
- var waveformDiv = document.createElement('div');
- waveformDiv.id = 'waveform';
- document.getElementsByTagName('body')[0].appendChild(waveformDiv);
- return WaveSurfer.create({
- container: '#waveform',
- waveColor: 'violet',
- progressColor: 'purple'
- });
- }
- beforeAll(function (done) {
- wavesurfer = __createWaveform();
- wavesurfer.load('/base/spec/support/demo.wav');
- wavesurfer.on('ready', function () {
- done();
- });
- });
- beforeEach(function () {
- wavesurfer.seekTo(0);
- });
- afterAll(function () {
- wavesurfer.destroy();
- });
- /**
- * @test {WaveSurfer#play}
- * @test {WaveSurfer#isPlaying}
- */
- it('should play', function () {
- wavesurfer.play();
- expect(wavesurfer.isPlaying()).toBeTrue();
- });
- /**
- * @test {WaveSurfer#play}
- * @test {WaveSurfer#isPlaying}
- * @test {WaveSurfer#pause}
- */
- it('should pause', function () {
- wavesurfer.play();
- expect(wavesurfer.isPlaying()).toBeTrue();
- wavesurfer.pause();
- expect(wavesurfer.isPlaying()).toBeFalse();
- });
- /**
- * @test {WaveSurfer#playPause}
- * @test {WaveSurfer#isPlaying}
- */
- it('should play or pause', function () {
- wavesurfer.playPause();
- expect(wavesurfer.isPlaying()).toBeTrue();
- wavesurfer.playPause();
- expect(wavesurfer.isPlaying()).toBeFalse();
- });
- /** @test {WaveSurfer#getDuration} */
- it('should get duration', function () {
- var duration = parseInt(wavesurfer.getDuration(), 10);
- expect(duration).toBeNumber();
- });
- /** @test {WaveSurfer#toggleMute} */
- it('should toggle mute', function () {
- wavesurfer.toggleMute();
- expect(wavesurfer.isMuted).toBeTrue();
- wavesurfer.toggleMute();
- expect(wavesurfer.isMuted).toBeFalse();
- });
- /** @test {WaveSurfer#setMute} */
- it('should set mute', function () {
- wavesurfer.setMute(true);
- expect(wavesurfer.isMuted).toBeTrue();
- wavesurfer.setMute(false);
- expect(wavesurfer.isMuted).toBeFalse();
- });
- /** @test {WaveSurfer#zoom} */
- it('should set zoom parameters', function () {
- wavesurfer.zoom(20);
- expect(wavesurfer.params.minPxPerSec).toEqual(20);
- expect(wavesurfer.params.scrollParent).toBe(true);
- });
- /** @test {WaveSurfer#zoom} */
- it('should set unzoom parameters', function () {
- wavesurfer.zoom(false);
- expect(wavesurfer.params.minPxPerSec).toEqual(wavesurfer.defaultParams.minPxPerSec);
- expect(wavesurfer.params.scrollParent).toBe(false);
- });
- });
|