Skip to content

Commit

Permalink
Prevent singlePlayer from returning null when forcing via config
Browse files Browse the repository at this point in the history
  • Loading branch information
albanqoku committed Nov 17, 2018
1 parent f9579cb commit 862fa2a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/singlePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ export default function createSinglePlayer (activePlayer) {
this.player = player
}
render () {
if (!activePlayer.canPlay(this.props.url)) {
const { forceVideo, forceAudio, forceHLS, forceDASH } = this.config.file
const skipCanPlay = forceVideo || forceAudio || forceHLS || forceDASH
if (!activePlayer.canPlay(this.props.url) && !skipCanPlay) {
return null
}
const { style, width, height, wrapper: Wrapper } = this.props
Expand Down
18 changes: 18 additions & 0 deletions test/singlePlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,21 @@ test('render', t => {
<Player activePlayer={FilePlayer} />
))
})

test('render - null', t => {
const wrapper = shallow(<SinglePlayer url='http://example.com/not-a-file-path' />)
t.true(wrapper.type() === null)
})

test('render - force via config', t => {
const wrapper = shallow(<SinglePlayer url='http://example.com/not-a-file-path' config={{ file: { forceVideo: true } }} />)
const player = wrapper.childAt(0)
t.true(player.is(Player))
t.true(player.prop('activePlayer') === FilePlayer)
t.true(player.prop('url') === 'http://example.com/not-a-file-path')

// This fails, but I don't know why
// t.true(wrapper.childAt(0).matchesElement(
// <Player activePlayer={FilePlayer} />
// ))
})

0 comments on commit 862fa2a

Please sign in to comment.