mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-02-26 00:54:04 +08:00
Great breakdown of React changes here: https://github.com/facebook/react/blob/master/CHANGELOG.md#0140-october-7-2015 Due to deprecation warnings, I don't think this will break third-party extensions unless they were doing really bad things.
52 lines
1.7 KiB
CoffeeScript
52 lines
1.7 KiB
CoffeeScript
_ = require "underscore"
|
|
React = require "react"
|
|
ReactDOM = require 'react-dom'
|
|
ReactTestUtils = require 'react-addons-test-utils'
|
|
|
|
Fields = require '../lib/fields'
|
|
CollapsedParticipants = require '../lib/collapsed-participants'
|
|
|
|
{Contact} = require 'nylas-exports'
|
|
|
|
describe "CollapsedParticipants", ->
|
|
makeField = (props={}) ->
|
|
@onClick = jasmine.createSpy("onClick")
|
|
props.onClick = @onClick
|
|
@fields = ReactTestUtils.renderIntoDocument(
|
|
<CollapsedParticipants {...props} />
|
|
)
|
|
|
|
it "fires callback when clicked", ->
|
|
makeField.call(@)
|
|
ReactTestUtils.Simulate.click ReactDOM.findDOMNode(@fields)
|
|
expect(@onClick).toHaveBeenCalled()
|
|
expect(@onClick.calls.length).toBe 1
|
|
|
|
numStr = ->
|
|
ReactDOM.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithClass(@fields, "num-remaining")).innerHTML
|
|
|
|
it "doesn't render num remaining when nothing remains", ->
|
|
makeField.call(@)
|
|
els = ReactTestUtils.scryRenderedDOMComponentsWithClass(@fields, "num-remaining")
|
|
expect(els.length).toBe 0
|
|
|
|
it "renders num remaining when remaining with no bcc", ->
|
|
makeField.call(@)
|
|
spyOn(@fields, "_setNumHiddenParticipants")
|
|
@fields.setState numRemaining: 10, numBccRemaining: 0
|
|
str = numStr.call(@)
|
|
expect(str).toBe "10 more"
|
|
|
|
it "renders num remaining when only bcc", ->
|
|
makeField.call(@)
|
|
spyOn(@fields, "_setNumHiddenParticipants")
|
|
@fields.setState numRemaining: 0, numBccRemaining: 5
|
|
str = numStr.call(@)
|
|
expect(str).toBe "5 Bcc"
|
|
|
|
it "renders num remaining when both remaining andj bcc", ->
|
|
makeField.call(@)
|
|
spyOn(@fields, "_setNumHiddenParticipants")
|
|
@fields.setState numRemaining: 10, numBccRemaining: 5
|
|
str = numStr.call(@)
|
|
expect(str).toBe "15 more (5 Bcc)"
|