mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-22 23:23:54 +08:00
fix(specs): Fix broken popover specs
- Remove composition with decorator for now - Fix other specs
This commit is contained in:
parent
a48ddd51f8
commit
a24e3444fd
3 changed files with 11 additions and 10 deletions
|
@ -50,6 +50,8 @@ describe 'ParticipantsTextField', ->
|
||||||
field={@fieldName}
|
field={@fieldName}
|
||||||
visible={true}
|
visible={true}
|
||||||
participants={@participants}
|
participants={@participants}
|
||||||
|
draft={clientId: 'draft-1'}
|
||||||
|
sessio={{}}
|
||||||
change={@propChange} />
|
change={@propChange} />
|
||||||
)
|
)
|
||||||
@renderedInput = ReactDOM.findDOMNode(@renderedField).querySelector('input')
|
@renderedInput = ReactDOM.findDOMNode(@renderedField).querySelector('input')
|
||||||
|
|
|
@ -12,7 +12,7 @@ ReactTestUtils = require('react-addons-test-utils')
|
||||||
|
|
||||||
CustomToken = React.createClass
|
CustomToken = React.createClass
|
||||||
render: ->
|
render: ->
|
||||||
<span>{@props.item.email}</span>
|
<span>{@props.token.email}</span>
|
||||||
|
|
||||||
CustomSuggestion = React.createClass
|
CustomSuggestion = React.createClass
|
||||||
render: ->
|
render: ->
|
||||||
|
@ -47,7 +47,7 @@ describe 'TokenizingTextField', ->
|
||||||
@propEmptied = jasmine.createSpy 'emptied'
|
@propEmptied = jasmine.createSpy 'emptied'
|
||||||
@propTokenKey = jasmine.createSpy("tokenKey").andCallFake (p) -> p.email
|
@propTokenKey = jasmine.createSpy("tokenKey").andCallFake (p) -> p.email
|
||||||
@propTokenIsValid = jasmine.createSpy("tokenIsValid").andReturn(true)
|
@propTokenIsValid = jasmine.createSpy("tokenIsValid").andReturn(true)
|
||||||
@propTokenNode = (p) -> <CustomToken item={p} />
|
@propTokenRenderer = CustomToken
|
||||||
@propOnTokenAction = jasmine.createSpy 'tokenAction'
|
@propOnTokenAction = jasmine.createSpy 'tokenAction'
|
||||||
@propCompletionNode = (p) -> <CustomSuggestion item={p} />
|
@propCompletionNode = (p) -> <CustomSuggestion item={p} />
|
||||||
@propCompletionsForInput = (input) => @completions
|
@propCompletionsForInput = (input) => @completions
|
||||||
|
@ -63,7 +63,7 @@ describe 'TokenizingTextField', ->
|
||||||
<TokenizingTextField
|
<TokenizingTextField
|
||||||
tokens={@tokens}
|
tokens={@tokens}
|
||||||
tokenKey={@propTokenKey}
|
tokenKey={@propTokenKey}
|
||||||
tokenNode={@propTokenNode}
|
tokenRenderer={@propTokenRenderer}
|
||||||
tokenIsValid={@propTokenIsValid}
|
tokenIsValid={@propTokenIsValid}
|
||||||
onRequestCompletions={@propCompletionsForInput}
|
onRequestCompletions={@propCompletionsForInput}
|
||||||
completionNode={@propCompletionNode}
|
completionNode={@propCompletionNode}
|
||||||
|
@ -86,14 +86,14 @@ describe 'TokenizingTextField', ->
|
||||||
it 'should render an input field', ->
|
it 'should render an input field', ->
|
||||||
expect(@renderedInput).toBeDefined()
|
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)
|
@renderedTokens = ReactTestUtils.scryRenderedComponentsWithType(@renderedField, CustomToken)
|
||||||
expect(@renderedTokens.length).toBe(@tokens.length)
|
expect(@renderedTokens.length).toBe(@tokens.length)
|
||||||
|
|
||||||
it 'shows the tokens in the correct order', ->
|
it 'shows the tokens in the correct order', ->
|
||||||
@renderedTokens = ReactTestUtils.scryRenderedComponentsWithType(@renderedField, CustomToken)
|
@renderedTokens = ReactTestUtils.scryRenderedComponentsWithType(@renderedField, CustomToken)
|
||||||
for i in [0..@tokens.length-1]
|
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", ->
|
describe "prop: tokenIsValid", ->
|
||||||
it "should be evaluated for each token when it's provided", ->
|
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 React, {Component, PropTypes} from 'react';
|
||||||
import {findDOMNode} from 'react-dom';
|
import {findDOMNode} from 'react-dom';
|
||||||
import Actions from '../flux/actions';
|
import Actions from '../flux/actions';
|
||||||
import AutoFocuses from './decorators/auto-focuses'
|
|
||||||
import compose from './decorators/compose'
|
|
||||||
|
|
||||||
|
|
||||||
const Directions = {
|
const Directions = {
|
||||||
|
@ -43,7 +41,6 @@ class FixedPopover extends Component {
|
||||||
height: PropTypes.number,
|
height: PropTypes.number,
|
||||||
width: PropTypes.number,
|
width: PropTypes.number,
|
||||||
}),
|
}),
|
||||||
focusElementWithTabIndex: PropTypes.func,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
@ -60,6 +57,7 @@ class FixedPopover extends Component {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.mounted = true;
|
this.mounted = true;
|
||||||
|
this.focusElementWithTabIndex()
|
||||||
findDOMNode(this.refs.popoverContainer).addEventListener('animationend', this.onAnimationEnd)
|
findDOMNode(this.refs.popoverContainer).addEventListener('animationend', this.onAnimationEnd)
|
||||||
window.addEventListener('resize', this.onWindowResize)
|
window.addEventListener('resize', this.onWindowResize)
|
||||||
_.defer(this.onPopoverRendered)
|
_.defer(this.onPopoverRendered)
|
||||||
|
@ -78,6 +76,7 @@ class FixedPopover extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
|
this.focusElementWithTabIndex()
|
||||||
_.defer(this.onPopoverRendered)
|
_.defer(this.onPopoverRendered)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +87,7 @@ class FixedPopover extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onAnimationEnd = () => {
|
onAnimationEnd = () => {
|
||||||
_.defer(this.props.focusElementWithTabIndex);
|
_.defer(this.focusElementWithTabIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
onWindowResize() {
|
onWindowResize() {
|
||||||
|
@ -343,4 +342,4 @@ class FixedPopover extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default compose(FixedPopover, AutoFocuses)
|
export default FixedPopover;
|
||||||
|
|
Loading…
Reference in a new issue