Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Oct 26, 2017
1 parent 91d1542 commit 9b4d1c4
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 5 deletions.
56 changes: 52 additions & 4 deletions test/specs/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const TEST_URLS = [
{
name: 'Vimeo',
url: 'https://vimeo.com/90509568',
error: 'http://vimeo.com/00000000',
seek: true
},
{
Expand All @@ -33,8 +34,7 @@ const TEST_URLS = [
},
{
name: 'Streamable',
url: 'https://streamable.com/moo',
skip: true
url: 'https://streamable.com/moo'
},
{
name: 'Vidme',
Expand Down Expand Up @@ -174,9 +174,56 @@ describe('ReactPlayer', () => {
div)
})
}

if (test.name === 'Vidme') {
it('plays a specific format', done => {
render(
<ReactPlayer
url='https://vid.me/GGho'
config={{ vidme: { format: '240p' } }}
onReady={() => done()}
/>,
div)
})

it('ignores an unknown format', done => {
render(
<ReactPlayer
url='https://vid.me/GGho'
config={{ vidme: { format: 'test-unknown-format' } }}
onReady={() => done()}
/>,
div)
})
}
})
}

describe('switching players', () => {
it('switches players', done => {
const switchPlayer = () => {
render(
<ReactPlayer
url='https://soundcloud.com/miami-nights-1984/accelerated'
playing
onPlay={() => done()}
/>,
div)
}
render(
<ReactPlayer
url='https://www.youtube.com/watch?v=M7lc1UVf-VE'
playing
onProgress={p => {
if (p.playedSeconds >= 3) {
switchPlayer()
}
}}
/>,
div)
})
})

describe('instance methods', () => {
let player
beforeEach(done => {
Expand Down Expand Up @@ -220,8 +267,9 @@ describe('ReactPlayer', () => {
it('renders with preload config', () => {
expect(player.wrapper).to.be.a('HTMLDivElement')
expect(player.wrapper.childNodes).to.have.length(3)
for (let div of player.wrapper.childNodes) {
expect(div.style.display).to.equal('none')
for (let node of player.wrapper.childNodes) {
expect(node).to.be.a('HTMLDivElement')
expect(node.style.display).to.equal('none')
}
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/specs/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('getConfig', () => {
preload: true
}
}
const config = getConfig(props, { config: {} })
const config = getConfig(props, { config: {} }, true)
expect(config).to.deep.equal({
youtube: {
playerVars: {
Expand Down

0 comments on commit 9b4d1c4

Please sign in to comment.