mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-12 06:21:30 +00:00
test: stabilize MediaPlayerContainer play-count harness
This commit is contained in:
parent
058e774351
commit
d7eb4dec9b
1 changed files with 11 additions and 2 deletions
|
|
@ -256,16 +256,25 @@ describe('MediaPlayerContainer', () => {
|
|||
}
|
||||
|
||||
cy.stub(win.HTMLMediaElement.prototype, 'load').callsFake(function load() {
|
||||
if (this.__absLoadedMetadataDispatched) return
|
||||
|
||||
this.__absLoadedMetadataDispatched = true
|
||||
this.dispatchEvent(new win.Event('loadedmetadata'))
|
||||
}).as('mediaLoad')
|
||||
|
||||
cy.stub(win.HTMLMediaElement.prototype, 'play').callsFake(function play() {
|
||||
if (this.__absIsPlaying) return Promise.resolve()
|
||||
|
||||
this.__absIsPlaying = true
|
||||
this.dispatchEvent(new win.Event('play'))
|
||||
this.dispatchEvent(new win.Event('playing'))
|
||||
return Promise.resolve()
|
||||
}).as('mediaPlay')
|
||||
}).as('mediaPlayCall')
|
||||
|
||||
cy.stub(win.HTMLMediaElement.prototype, 'pause').callsFake(function pause() {
|
||||
if (!this.__absIsPlaying) return
|
||||
|
||||
this.__absIsPlaying = false
|
||||
this.dispatchEvent(new win.Event('pause'))
|
||||
}).as('mediaPause')
|
||||
})
|
||||
|
|
@ -284,7 +293,7 @@ describe('MediaPlayerContainer', () => {
|
|||
cy.get('button[aria-label="Play"]').click()
|
||||
|
||||
cy.get('@mediaLoad').should('have.been.called')
|
||||
cy.get('@mediaPlay').should('have.been.calledOnce')
|
||||
cy.get('@mediaPlayCall').should('have.been.calledTwice')
|
||||
cy.get('@createMediaElementSource').should('have.been.calledOnce')
|
||||
cy.get('audio#audio-player').should(($audio) => {
|
||||
expect($audio[0].src).to.include(FIXTURE_URL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue