Skip to content

Commit

Permalink
Add failing onDuration test
Browse files Browse the repository at this point in the history
To duplicate the issue outlined in #52
  • Loading branch information
cookpete committed Jun 1, 2016
1 parent 1e5c9e9 commit 564243e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/karma/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ describe('ReactPlayer', () => {

const testDuration = (url, done) => {
const onDuration = (duration) => {
if (duration && duration > 0) done()
const error = duration && duration > 0 ? null : new Error('Invalid duration: ' + error)
done(error)
}
render(<ReactPlayer url={url} playing onDuration={onDuration} />, div)
}

const testDurationDelayed = (url, done) => {
render(<ReactPlayer url={url} playing={false} />, div, () => {
testDuration(url, done)
})
}

const testError = (url, onError) => {
render(<ReactPlayer url={url} playing onError={() => onError()} />, div)
}
Expand All @@ -60,6 +67,7 @@ describe('ReactPlayer', () => {
it('fires onPlay', (done) => testPlay(TEST_YOUTUBE_URL, done))
it('fires onPause', (done) => testPause(TEST_YOUTUBE_URL, done))
it('fires onDuration', (done) => testDuration(TEST_YOUTUBE_URL, done))
it('fires onDuration with delayed load', (done) => testDurationDelayed(TEST_YOUTUBE_URL, done))
it('fires onError', (done) => testError(TEST_YOUTUBE_ERROR, done))

it('starts at a specified time', (done) => {
Expand All @@ -75,6 +83,7 @@ describe('ReactPlayer', () => {
it('fires onPlay', (done) => testPlay(TEST_SOUNDCLOUD_URL, done))
it('fires onPause', (done) => testPause(TEST_SOUNDCLOUD_URL, done))
it('fires onDuration', (done) => testDuration(TEST_SOUNDCLOUD_URL, done))
it('fires onDuration with delayed load', (done) => testDurationDelayed(TEST_SOUNDCLOUD_URL, done))
it('fires onError', (done) => testError(TEST_SOUNDCLOUD_ERROR, done))
})

Expand All @@ -83,13 +92,15 @@ describe('ReactPlayer', () => {
it('fires onPlay', (done) => testPlay(TEST_VIMEO_URL, done))
it('fires onPause', (done) => testPause(TEST_VIMEO_URL, done))
it('fires onDuration', (done) => testDuration(TEST_VIMEO_URL, done))
it('fires onDuration with delayed load', (done) => testDurationDelayed(TEST_VIMEO_URL, done))
})

describe('FilePlayer', () => {
it('fires onStart', (done) => testStart(TEST_FILE_URL, done))
it('fires onPlay', (done) => testPlay(TEST_FILE_URL, done))
it('fires onPause', (done) => testPause(TEST_FILE_URL, done))
it('fires onDuration', (done) => testDuration(TEST_FILE_URL, done))
it('fires onDuration with delayed load', (done) => testDurationDelayed(TEST_FILE_URL, done))
it.skip('fires onError', (done) => testError(TEST_FILE_ERROR, done))
})

Expand Down

0 comments on commit 564243e

Please sign in to comment.