mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 10:33:56 +08:00
fix(specs): Fix broken popover specs
- Remove composition with decorator for now - Fix other specs
This commit is contained in:
parent
a46bad4eb7
commit
e710a83e10
3 changed files with 11 additions and 10 deletions
|
@ -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')
|
||||
|
|
|
@ -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", ->
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue