fix(specs): Fix broken popover specs

- Remove composition with decorator for now
- Fix other specs
This commit is contained in:
Juan Tejada 2016-04-24 11:07:53 -07:00
parent a48ddd51f8
commit a24e3444fd
3 changed files with 11 additions and 10 deletions

View file

@ -50,6 +50,8 @@ describe 'ParticipantsTextField', ->
field={@fieldName}
visible={true}
participants={@participants}
draft={clientId: 'draft-1'}
sessio={{}}
change={@propChange} />
)
@renderedInput = ReactDOM.findDOMNode(@renderedField).querySelector('input')

View file

@ -12,7 +12,7 @@ ReactTestUtils = require('react-addons-test-utils')
CustomToken = React.createClass
render: ->
<span>{@props.item.email}</span>
<span>{@props.token.email}</span>
CustomSuggestion = React.createClass
render: ->
@ -47,7 +47,7 @@ describe 'TokenizingTextField', ->
@propEmptied = jasmine.createSpy 'emptied'
@propTokenKey = jasmine.createSpy("tokenKey").andCallFake (p) -> p.email
@propTokenIsValid = jasmine.createSpy("tokenIsValid").andReturn(true)
@propTokenNode = (p) -> <CustomToken item={p} />
@propTokenRenderer = CustomToken
@propOnTokenAction = jasmine.createSpy 'tokenAction'
@propCompletionNode = (p) -> <CustomSuggestion item={p} />
@propCompletionsForInput = (input) => @completions
@ -63,7 +63,7 @@ describe 'TokenizingTextField', ->
<TokenizingTextField
tokens={@tokens}
tokenKey={@propTokenKey}
tokenNode={@propTokenNode}
tokenRenderer={@propTokenRenderer}
tokenIsValid={@propTokenIsValid}
onRequestCompletions={@propCompletionsForInput}
completionNode={@propCompletionNode}
@ -86,14 +86,14 @@ describe 'TokenizingTextField', ->
it 'should render an input field', ->
expect(@renderedInput).toBeDefined()
it 'shows the tokens provided by the tokenNode method', ->
it 'shows the tokens provided by the tokenRenderer', ->
@renderedTokens = ReactTestUtils.scryRenderedComponentsWithType(@renderedField, CustomToken)
expect(@renderedTokens.length).toBe(@tokens.length)
it 'shows the tokens in the correct order', ->
@renderedTokens = ReactTestUtils.scryRenderedComponentsWithType(@renderedField, CustomToken)
for i in [0..@tokens.length-1]
expect(@renderedTokens[i].props.item).toBe(@tokens[i])
expect(@renderedTokens[i].props.token).toBe(@tokens[i])
describe "prop: tokenIsValid", ->
it "should be evaluated for each token when it's provided", ->

View file

@ -2,8 +2,6 @@ import _ from 'underscore';
import React, {Component, PropTypes} from 'react';
import {findDOMNode} from 'react-dom';
import Actions from '../flux/actions';
import AutoFocuses from './decorators/auto-focuses'
import compose from './decorators/compose'
const Directions = {
@ -43,7 +41,6 @@ class FixedPopover extends Component {
height: PropTypes.number,
width: PropTypes.number,
}),
focusElementWithTabIndex: PropTypes.func,
};
constructor(props) {
@ -60,6 +57,7 @@ class FixedPopover extends Component {
componentDidMount() {
this.mounted = true;
this.focusElementWithTabIndex()
findDOMNode(this.refs.popoverContainer).addEventListener('animationend', this.onAnimationEnd)
window.addEventListener('resize', this.onWindowResize)
_.defer(this.onPopoverRendered)
@ -78,6 +76,7 @@ class FixedPopover extends Component {
}
componentDidUpdate() {
this.focusElementWithTabIndex()
_.defer(this.onPopoverRendered)
}
@ -88,7 +87,7 @@ class FixedPopover extends Component {
}
onAnimationEnd = () => {
_.defer(this.props.focusElementWithTabIndex);
_.defer(this.focusElementWithTabIndex);
}
onWindowResize() {
@ -343,4 +342,4 @@ class FixedPopover extends Component {
}
}
export default compose(FixedPopover, AutoFocuses)
export default FixedPopover;