From e710a83e10ca944832745c2a9132a70bec92f29b Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Sun, 24 Apr 2016 11:07:53 -0700 Subject: [PATCH] fix(specs): Fix broken popover specs - Remove composition with decorator for now - Fix other specs --- spec/components/participants-text-field-spec.cjsx | 2 ++ spec/components/tokenizing-text-field-spec.cjsx | 10 +++++----- src/components/fixed-popover.jsx | 9 ++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/spec/components/participants-text-field-spec.cjsx b/spec/components/participants-text-field-spec.cjsx index 59e5a1ff5..afd5bb70b 100644 --- a/spec/components/participants-text-field-spec.cjsx +++ b/spec/components/participants-text-field-spec.cjsx @@ -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') diff --git a/spec/components/tokenizing-text-field-spec.cjsx b/spec/components/tokenizing-text-field-spec.cjsx index 667929230..076ca354a 100644 --- a/spec/components/tokenizing-text-field-spec.cjsx +++ b/spec/components/tokenizing-text-field-spec.cjsx @@ -12,7 +12,7 @@ ReactTestUtils = require('react-addons-test-utils') CustomToken = React.createClass render: -> - {@props.item.email} + {@props.token.email} 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) -> + @propTokenRenderer = CustomToken @propOnTokenAction = jasmine.createSpy 'tokenAction' @propCompletionNode = (p) -> @propCompletionsForInput = (input) => @completions @@ -63,7 +63,7 @@ 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", -> diff --git a/src/components/fixed-popover.jsx b/src/components/fixed-popover.jsx index f5a50e2ea..4b0157653 100644 --- a/src/components/fixed-popover.jsx +++ b/src/components/fixed-popover.jsx @@ -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;