2015-09-14 22:37:00 +08:00
|
|
|
_ = require "underscore"
|
2016-03-29 16:41:24 +08:00
|
|
|
React = require "react"
|
|
|
|
ReactDOM = require 'react-dom'
|
|
|
|
ReactTestUtils = require 'react-addons-test-utils'
|
|
|
|
|
2016-05-04 07:42:28 +08:00
|
|
|
Fields = require('../lib/fields').default
|
|
|
|
CollapsedParticipants = require('../lib/collapsed-participants').default
|
2015-09-14 22:37:00 +08:00
|
|
|
|
|
|
|
{Contact} = require 'nylas-exports'
|
|
|
|
|
|
|
|
describe "CollapsedParticipants", ->
|
|
|
|
makeField = (props={}) ->
|
|
|
|
@fields = ReactTestUtils.renderIntoDocument(
|
|
|
|
<CollapsedParticipants {...props} />
|
|
|
|
)
|
|
|
|
|
|
|
|
numStr = ->
|
2016-03-29 16:41:24 +08:00
|
|
|
ReactDOM.findDOMNode(ReactTestUtils.findRenderedDOMComponentWithClass(@fields, "num-remaining")).innerHTML
|
2015-09-14 22:37:00 +08:00
|
|
|
|
|
|
|
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)"
|