Skip to content

Commit

Permalink
Remove the need for array.find polyfill
Browse files Browse the repository at this point in the history
2.0.0 was causing errors on older node versions, and it wasn't worth the trouble
  • Loading branch information
cookpete committed Feb 3, 2016
1 parent 736ef37 commit 7aa4719
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
"whatwg-fetch": "^0.11.0"
},
"dependencies": {
"array.prototype.find": "^2.0.0",
"load-script": "^1.0.0",
"query-string": "^3.0.0"
},
Expand Down
18 changes: 11 additions & 7 deletions test/mocha/ReactPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react'
import { describe, it, beforeEach } from 'mocha'
import { expect } from 'chai'
import { createRenderer } from 'react-addons-test-utils'
import 'array.prototype.find'

import ReactPlayer from '../../src/ReactPlayer'
import YouTube from '../../src/players/YouTube'
Expand All @@ -25,32 +24,37 @@ describe('ReactPlayer', () => {
it('renders YouTube player', () => {
shallowRenderer.render(<ReactPlayer url={YOUTUBE_URL} />)
const result = shallowRenderer.getRenderOutput()
const activePlayer = getActivePlayer(result)
const activePlayer = getActivePlayer(result.props.children)
expect(activePlayer.type).to.equal(YouTube)
})

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

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

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

function getActivePlayer (result) {
return result.props.children.find(player => player.ref === 'player')
function getActivePlayer (children) {
for (let i = 0; i !== children.length; i++) {
if (children[i].ref === 'player') {
return children[i]
}
}
return null
}

0 comments on commit 7aa4719

Please sign in to comment.