Skip to content

Commit

Permalink
Add very basic shallow rendering tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cookpete committed Oct 19, 2015
1 parent 6cd433f commit 7beccbe
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"mocha": "^2.2.5",
"react": "^0.14.0",
"react-dom": "^0.14.0",
"react-addons-test-utils": "^0.14.0",
"react-hot-loader": "^1.2.7",
"standard": "^5.1.0",
"webpack": "^1.9.6",
Expand Down
47 changes: 47 additions & 0 deletions test/ReactPlayer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import React from 'react'
import { describe, it, beforeEach } from 'mocha'
import { expect } from 'chai'
import { createRenderer } from 'react-addons-test-utils'

import ReactPlayer from '../src/ReactPlayer'
import YouTube from '../src/players/YouTube'
import Vimeo from '../src/players/Vimeo'
import SoundCloud from '../src/players/SoundCloud'
import FilePlayer from '../src/players/FilePlayer'

const YOUTUBE_URL = 'https://www.youtube.com/watch?v=oUFJJNQGwhk'
const SOUNDCLOUD_URL = 'https://soundcloud.com/miami-nights-1984/accelerated'
const VIMEO_URL = 'https://vimeo.com/90509568'
const FILE_URL = 'https://example.com/video.mp4'

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

beforeEach(() => {
shallowRenderer = createRenderer()
})

it('renders YouTube player', () => {
shallowRenderer.render(<ReactPlayer url={YOUTUBE_URL} />)
const result = shallowRenderer.getRenderOutput()
expect(result.props.children.type).to.equal(YouTube)
})

it('renders SoundCloud player', () => {
shallowRenderer.render(<ReactPlayer url={SOUNDCLOUD_URL} />)
const result = shallowRenderer.getRenderOutput()
expect(result.props.children.type).to.equal(SoundCloud)
})

it('renders Vimeo player', () => {
shallowRenderer.render(<ReactPlayer url={VIMEO_URL} />)
const result = shallowRenderer.getRenderOutput()
expect(result.props.children.type).to.equal(Vimeo)
})

it('renders FilePlayer', () => {
shallowRenderer.render(<ReactPlayer url={FILE_URL} />)
const result = shallowRenderer.getRenderOutput()
expect(result.props.children.type).to.equal(FilePlayer)
})
})

0 comments on commit 7beccbe

Please sign in to comment.