Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/middleware/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function find(selector){

let elements, name
if (!(typeof selector === "string")) {
name = selector.name.toLowerCase()
name = (selector.name || selector.displayName).toLowerCase()
elements = TestUtils.scryRenderedComponentsWithType(this.instance, selector)
} else if (selector.match(/\./)) {
selector = selector.replace(/\./, '')
Expand Down
2 changes: 2 additions & 0 deletions tests/components/component.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { Component } from 'react'
import TinyComponent from './tiny-component'
import OtherComponent from './other-component'

export default class TestComponent extends Component {
constructor(props, context){
Expand All @@ -23,6 +24,7 @@ export default class TestComponent extends Component {
Click Me
</button>
<TinyComponent test="true"/>
<OtherComponent test="true"/>
</section>
)
}
Expand Down
7 changes: 7 additions & 0 deletions tests/components/other-component.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react'

export default React.createClass({
render: function() {
return <span className="bar"></span>
}
})
10 changes: 10 additions & 0 deletions tests/find.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Find } from '../src/middleware'
import { expect } from 'chai'

import { TestComponent, TinyComponent } from './components'
import OtherComponent from './components/other-component'

describe('Find middleware', () => {
it('should find div', () => {
Expand Down Expand Up @@ -35,4 +36,13 @@ describe('Find middleware', () => {
expect(tinycomponent.props.test).to.be.equal('true')
})
})

it('should find a rendered component created with `createClass`', () => {
Test(<TestComponent/>)
.find(OtherComponent)
.test(function() {
let otherComponent = this.elements['other-component']
expect(otherComponent.props.test).to.be.equal('true')
})
})
})