-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
115 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
var webpackConfig = require('../webpack.config.dev') | ||
webpackConfig.devtool = 'inline-source-map' | ||
|
||
module.exports = function (config) { | ||
config.set({ | ||
browsers: process.env.CONTINUOUS_INTEGRATION ? [ 'ChromeTravis' ] : [ 'Chrome', 'Firefox' ], | ||
singleRun: true, | ||
frameworks: [ 'mocha', 'chai' ], | ||
files: [ | ||
'karma.webpack.js' | ||
], | ||
preprocessors: { | ||
'karma.webpack.js': [ 'webpack', 'sourcemap' ] | ||
}, | ||
reporters: [ 'mocha' ], | ||
webpack: webpackConfig, | ||
webpackServer: { | ||
noInfo: true | ||
}, | ||
client: { | ||
mocha: { | ||
timeout: 10000 | ||
} | ||
}, | ||
customLaunchers: { | ||
ChromeTravis: { | ||
base: 'Chrome', | ||
flags: ['--no-sandbox'] | ||
} | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
var context = require.context('./karma', true, /\.js$/) | ||
context.keys().forEach(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from 'react' | ||
import { render, unmountComponentAtNode } from 'react-dom' | ||
|
||
import ReactPlayer from '../../src/ReactPlayer' | ||
|
||
const { describe, it, beforeEach, afterEach } = window | ||
const TEST_YOUTUBE_URL = 'https://www.youtube.com/watch?v=GlCmAC4MHek' | ||
const TEST_SOUNDCLOUD_URL = 'https://soundcloud.com/miami-nights-1984/accelerated' | ||
const TEST_VIMEO_URL = 'https://vimeo.com/90509568' | ||
const TEST_FILE_URL = 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.ogv' | ||
|
||
describe('ReactPlayer', () => { | ||
let div | ||
|
||
beforeEach(() => { | ||
div = document.createElement('div') | ||
document.body.appendChild(div) | ||
}) | ||
|
||
afterEach(() => { | ||
unmountComponentAtNode(div) | ||
document.body.removeChild(div) | ||
}) | ||
|
||
const testPlay = (url, onPlay) => { | ||
render(<ReactPlayer url={url} playing onPlay={onPlay} />, div) | ||
} | ||
|
||
const testPause = (url, done) => { | ||
const onPlay = () => { | ||
setTimeout(() => { | ||
render(<ReactPlayer url={url} playing={false} onPause={done} />, div) | ||
}, 500) | ||
} | ||
testPlay(url, onPlay) | ||
} | ||
|
||
it('plays a YouTube video', done => testPlay(TEST_YOUTUBE_URL, done)) | ||
it('plays a SoundCloud track', done => testPlay(TEST_SOUNDCLOUD_URL, done)) | ||
it('plays a Vimeo video', done => testPlay(TEST_VIMEO_URL, done)) | ||
it('plays a file', done => testPlay(TEST_FILE_URL, done)) | ||
|
||
it('pauses a YouTube video', done => testPause(TEST_YOUTUBE_URL, done)) | ||
it('pauses a SoundCloud track', done => testPause(TEST_SOUNDCLOUD_URL, done)) | ||
it('pauses a Vimeo video', done => testPause(TEST_VIMEO_URL, done)) | ||
it('pauses a file', done => testPause(TEST_FILE_URL, done)) | ||
|
||
it('switches between media', function (done) { | ||
const renderPlayer = (url, onPlay) => render(<ReactPlayer url={url} playing onPlay={onPlay} />, div) | ||
const renderFilePlayer = () => renderPlayer(TEST_FILE_URL, done) | ||
const renderVimeoPlayer = () => renderPlayer(TEST_VIMEO_URL, renderFilePlayer) | ||
const renderSoundCloudPlayer = () => renderPlayer(TEST_SOUNDCLOUD_URL, renderVimeoPlayer) | ||
renderPlayer(TEST_YOUTUBE_URL, renderSoundCloudPlayer) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters