mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-11 18:32:20 +08:00
980199a703
Summary: Participants now collapse Gmail style in the composer field. New, more declarative system for how we deal with "focusedFields" on the composer. Extracted a `CollapsedParticipants` and `ExpandedParticipants` component. Test Plan: TODO Reviewers: dillon, bengotow Reviewed By: bengotow Differential Revision: https://phab.nylas.com/D2013
50 lines
1.7 KiB
CoffeeScript
50 lines
1.7 KiB
CoffeeScript
_ = require "underscore"
|
|
React = require "react/addons"
|
|
Fields = require '../lib/fields'
|
|
ReactTestUtils = React.addons.TestUtils
|
|
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 React.findDOMNode(@fields)
|
|
expect(@onClick).toHaveBeenCalled()
|
|
expect(@onClick.calls.length).toBe 1
|
|
|
|
numStr = ->
|
|
React.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)"
|