mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-12 12:40:08 +08:00
7190ca69f7
Summary: Major ID refactor Test Plan: edgehill --test Reviewers: bengotow, dillon Differential Revision: https://phab.nylas.com/D1946
56 lines
1.7 KiB
CoffeeScript
56 lines
1.7 KiB
CoffeeScript
React = require "react/addons"
|
|
proxyquire = require("proxyquire").noPreserveCache()
|
|
ReactTestUtils = React.addons.TestUtils
|
|
|
|
{Thread,
|
|
Message,
|
|
DraftStore} = require 'nylas-exports'
|
|
|
|
class MessageItem extends React.Component
|
|
@displayName: "StubMessageItem"
|
|
render: -> <span></span>
|
|
|
|
MessageItemContainer = proxyquire '../lib/message-item-container',
|
|
"./message-item": MessageItem
|
|
|
|
{InjectedComponent} = require 'nylas-component-kit'
|
|
|
|
testThread = new Thread(id: "t1")
|
|
testClientId = "local-id"
|
|
testMessage = new Message(id: "m1", draft: false, unread: true)
|
|
testDraft = new Message(id: "d1", draft: true, unread: true)
|
|
|
|
describe 'MessageItemContainer', ->
|
|
|
|
beforeEach ->
|
|
@isSendingDraft = false
|
|
spyOn(DraftStore, "isSendingDraft").andCallFake => @isSendingDraft
|
|
|
|
renderContainer = (message) ->
|
|
ReactTestUtils.renderIntoDocument(
|
|
<MessageItemContainer thread={testThread}
|
|
message={message}
|
|
draftClientId={testClientId} />
|
|
)
|
|
|
|
it "shows composer if it's a draft", ->
|
|
@isSendingDraft = false
|
|
doc = renderContainer(testDraft)
|
|
items = ReactTestUtils.scryRenderedComponentsWithType(doc,
|
|
InjectedComponent)
|
|
expect(items.length).toBe 1
|
|
|
|
it "shows a pending message if it's a sending draft", ->
|
|
@isSendingDraft = true
|
|
doc = renderContainer(testDraft)
|
|
items = ReactTestUtils.scryRenderedComponentsWithType(doc,
|
|
MessageItem)
|
|
expect(items.length).toBe 1
|
|
expect(items[0].props.pending).toBe true
|
|
|
|
it "renders a message if it's not a draft", ->
|
|
@isSendingDraft = false
|
|
doc = renderContainer(testMessage)
|
|
items = ReactTestUtils.scryRenderedComponentsWithType(doc,
|
|
MessageItem)
|
|
expect(items.length).toBe 1
|