Skip to content

Commit

Permalink
test: cover _hls.loadSource call on inital play case
Browse files Browse the repository at this point in the history
  • Loading branch information
joaopaulovieira committed Jan 31, 2021
1 parent 504277c commit d47944d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/hls.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,26 @@ describe('HlsjsPlayback', () => {
expect(playback._manifestParsed).toBeTruthy()
})
})

describe('play method', () => {
test('calls this._hls.loadSource if _manifestParsed flag and options.hlsPlayback.loadSourceBeforePlay are falsy', () => {
const playback = new HlsjsPlayback({ src: 'http://clappr.io/foo.m3u8', hlsjsPlayback: { loadSourceBeforePlay: true } })
playback._setup()
jest.spyOn(playback._hls, 'loadSource')
playback.play()

expect(playback._hls.loadSource).not.toHaveBeenCalled()

playback.options.hlsPlayback.loadSourceBeforePlay = false
playback._manifestParsed = true
playback.play()

expect(playback._hls.loadSource).not.toHaveBeenCalled()

playback._manifestParsed = false
playback.play()

expect(playback._hls.loadSource).toHaveBeenCalledTimes(1)
})
})
})

0 comments on commit d47944d

Please sign in to comment.