-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add test cases for abort and destroy
- Loading branch information
Showing
1 changed file
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
describe('WaveSurfer abort handling tests', () => { | ||
beforeEach(() => { | ||
cy.visit('cypress/e2e/index.html') | ||
|
||
cy.window().its('WaveSurfer').should('exist') | ||
}) | ||
|
||
// https://github.com/katspaugh/wavesurfer.js/issues/3637 | ||
it('load url after destroyed should emit ready', () => { | ||
cy.window().then((win) => { | ||
return new Promise((resolve) => { | ||
win.wavesurfer = win.WaveSurfer.create({ | ||
container: '#waveform', | ||
height: 200, | ||
waveColor: 'rgb(200, 200, 0)', | ||
progressColor: 'rgb(100, 100, 0)', | ||
}) | ||
|
||
win.wavesurfer.destroy() | ||
|
||
win.wavesurfer.load('../../examples/audio/demo.wav') | ||
|
||
win.wavesurfer.on('ready', resolve) | ||
}) | ||
}) | ||
}) | ||
|
||
it('destroy before wavesurfer ready should throw AbortError Exception', () => { | ||
cy.window().then((win) => { | ||
return new Promise((resolve) => { | ||
win.wavesurfer = win.WaveSurfer.create({ | ||
container: '#waveform', | ||
height: 200, | ||
waveColor: 'rgb(200, 200, 0)', | ||
progressColor: 'rgb(100, 100, 0)', | ||
}) | ||
|
||
// catch load error | ||
win.wavesurfer.load('../../examples/audio/demo.wav').catch((e) => { | ||
expect(e.name).to.equal('AbortError') | ||
expect(e.message).to.equal('The user aborted a request.') | ||
resolve() | ||
}) | ||
|
||
win.wavesurfer.destroy() | ||
}) | ||
}) | ||
}) | ||
|
||
it('destroy before wavesurfer ready should emit AbortError Exception', () => { | ||
cy.window().then((win) => { | ||
return new Promise((resolve) => { | ||
win.wavesurfer = win.WaveSurfer.create({ | ||
container: '#waveform', | ||
height: 200, | ||
waveColor: 'rgb(200, 200, 0)', | ||
progressColor: 'rgb(100, 100, 0)', | ||
}) | ||
|
||
win.wavesurfer.load('../../examples/audio/demo.wav').catch(() => {}) | ||
|
||
win.wavesurfer.destroy() | ||
|
||
// listening wavesurfer emit error event | ||
win.wavesurfer.on('error', (e) => { | ||
expect(e.name).to.equal('AbortError') | ||
expect(e.message).to.equal('The user aborted a request.') | ||
resolve() | ||
}) | ||
}) | ||
}) | ||
}) | ||
}) |