fix:(specs) for message list

This commit is contained in:
Evan Morikawa 2015-03-31 17:04:10 -07:00
parent 231f31ecf7
commit 911d7f961d
2 changed files with 13 additions and 11 deletions

View file

@ -212,6 +212,7 @@ describe "MessageList", ->
describe "Populated Message list", ->
beforeEach ->
MessageStore._items = testMessages
MessageStore._expandItemsToDefault()
MessageStore.trigger(MessageStore)
@message_list.setState currentThread: test_thread
@ -220,6 +221,10 @@ describe "MessageList", ->
MessageItem)
expect(items.length).toBe 5
it "renders the correct number of expanded messages", ->
msgs = TestUtils.scryRenderedDOMComponentsWithClass(@message_list, "message-item-wrap collapsed")
expect(msgs.length).toBe 4
it "aggregates participants across all messages", ->
expect(@message_list._threadParticipants().length).toBe 4
expect(@message_list._threadParticipants()[0] instanceof Contact).toBe true
@ -227,13 +232,7 @@ describe "MessageList", ->
it "displays lists of participants on the page", ->
items = TestUtils.scryRenderedComponentsWithType(@message_list,
MessageParticipants)
expect(items.length).toBe 5
# We no longer do this (for now)
# it "displays the thread participants on the page", ->
# items = TestUtils.scryRenderedComponentsWithType(@message_list,
# ParticipantsItem)
# expect(items.length).toBe 1
expect(items.length).toBe 1
it "focuses new composers when a draft is added", ->
spyOn(@message_list, "_focusDraft")

View file

@ -111,10 +111,7 @@ MessageStore = Reflux.createStore
atom.inbox.getCollection namespace.id, 'messages', {thread_id: @_threadId}
loaded = false
# Expand all unread messages, all drafts, and the last message
for item, idx in @_items
if item.unread or item.draft or idx is @_items.length - 1
@_itemsExpanded[item.id] = true
@_expandItemsToDefault()
# Check that expanded messages have bodies. We won't mark ourselves
# as loaded until they're all available. Note that items can be manually
@ -139,6 +136,12 @@ MessageStore = Reflux.createStore
@_itemsLoading = false
@trigger(@)
# Expand all unread messages, all drafts, and the last message
_expandItemsToDefault: ->
for item, idx in @_items
if item.unread or item.draft or idx is @_items.length - 1
@_itemsExpanded[item.id] = true
_fetchMessageIdFromAPI: (id) ->
return if @_inflight[id]