Skip to content

Commit

Permalink
Player test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Sep 9, 2017
1 parent a4262d5 commit c0ee179
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions test/karma/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ const { describe, it, expect, beforeEach, afterEach } = window
const TEST_URLS = [
{
name: 'YouTube',
url: 'https://www.youtube.com/watch?v=M7lc1UVf-VE'
url: 'https://www.youtube.com/watch?v=M7lc1UVf-VE',
error: 'https://www.youtube.com/watch?v=xxxxxxxxxxx'
},
{
name: 'SoundCloud',
url: 'https://soundcloud.com/miami-nights-1984/accelerated'
url: 'https://soundcloud.com/miami-nights-1984/accelerated',
error: 'https://soundcloud.com/xxxxxxxxxxx/xxxxxxxxxxx'
},
{
name: 'Facebook',
Expand Down Expand Up @@ -46,7 +48,8 @@ const TEST_URLS = [
},
{
name: 'FilePlayer',
url: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv'
url: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv',
error: 'http://example.com/error.ogv'
},
{
name: 'FilePlayer (multiple sources)',
Expand All @@ -66,21 +69,6 @@ const TEST_URLS = [
}
]

const TEST_ERROR_URLS = [
{
name: 'YouTube',
url: 'https://www.youtube.com/watch?v=xxxxxxxxxxx'
},
{
name: 'SoundCloud',
url: 'https://soundcloud.com/xxxxxxxxxxx/xxxxxxxxxxx'
},
{
name: 'FilePlayer',
url: 'http://example.com/error.ogv'
}
]

describe('ReactPlayer', () => {
let div

Expand All @@ -98,6 +86,7 @@ describe('ReactPlayer', () => {
const desc = test.skip ? describe.skip : describe
desc(test.name, () => {
it('onReady, onStart, onPlay, onDuration, onProgress', done => {
// Use a count object to ensure everything is called at least once
let count = {}
const bump = key => {
count[key] = count[key] || 0
Expand Down Expand Up @@ -125,20 +114,18 @@ describe('ReactPlayer', () => {
/>,
div)
})
})
}

for (let test of TEST_ERROR_URLS) {
describe(test.name, () => {
it('onError', done => {
render(
<ReactPlayer
url={test.url}
playing
onError={() => done()}
/>,
div)
})
if (test.error) {
it('onError', done => {
render(
<ReactPlayer
url={test.error}
playing
onError={() => done()}
/>,
div)
})
}
})
}
})

0 comments on commit c0ee179

Please sign in to comment.