From 18165d5ebb4d9c8dc63152e10016bb7d59966cb6 Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Mon, 30 Mar 2015 11:21:23 -0700 Subject: [PATCH] fix(spec): fix thread list participants name undefined error Summary: A change in the spec caused an error when message metatdata wasn't available. The specs were also not updated to reflect the change. fix thread list participants spec fix thread list spec Test Plan: edgehill --test Reviewers: bengotow Reviewed By: bengotow Differential Revision: https://review.inboxapp.com/D1372 --- .../lib/thread-list-participants.cjsx | 5 ++ .../spec/thread-list-participants-spec.cjsx | 50 +++++++++++++------ .../thread-list/spec/thread-list-spec.cjsx | 5 +- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/internal_packages/thread-list/lib/thread-list-participants.cjsx b/internal_packages/thread-list/lib/thread-list-participants.cjsx index 93cad1f9c..ca16b0d90 100644 --- a/internal_packages/thread-list/lib/thread-list-participants.cjsx +++ b/internal_packages/thread-list/lib/thread-list-participants.cjsx @@ -63,6 +63,11 @@ ThreadListParticipants = React.createClass if list.length is 0 list.push(@props.thread.participants[0]) + # Change the list to have the appropriate output format + list = list.map (contact) -> + contact: contact + unread: false # We don't have the data. + # We only ever want to show three. Ben...Kevin... Marty # But we want the *right* three. if list.length > 3 diff --git a/internal_packages/thread-list/spec/thread-list-participants-spec.cjsx b/internal_packages/thread-list/spec/thread-list-participants-spec.cjsx index e964ce84d..3b94c1be9 100644 --- a/internal_packages/thread-list/spec/thread-list-participants-spec.cjsx +++ b/internal_packages/thread-list/spec/thread-list-participants-spec.cjsx @@ -40,20 +40,20 @@ describe "ThreadListParticipants", -> in: [ new Message(unread: false, from: [@ben]), ] - out: [@ben] + out: [{contact: @ben, unread: false}] },{ name: 'single unread email' in: [ new Message(unread: true, from: [@evan]), ] - out: [@evan] + out: [{contact: @evan, unread: true}] },{ name: 'single unread response' in: [ new Message(unread: false, from: [@ben]), new Message(unread: true, from: [@evan]), ] - out: [@ben, @evan] + out: [{contact: @ben, unread: false}, {contact: @evan, unread: true}] },{ name: 'two unread responses' in: [ @@ -61,7 +61,9 @@ describe "ThreadListParticipants", -> new Message(unread: true, from: [@evan]), new Message(unread: true, from: [@kavya]), ] - out: [@ben, @evan, @kavya] + out: [{contact: @ben, unread: false}, + {contact: @evan, unread: true}, + {contact: @kavya, unread: true}] },{ name: 'two unread responses (repeated participants)' in: [ @@ -69,7 +71,7 @@ describe "ThreadListParticipants", -> new Message(unread: true, from: [@evan]), new Message(unread: true, from: [@evanAgain]), ] - out: [@ben, @evan] + out: [{contact: @ben, unread: false}, {contact: @evan, unread: true}] },{ name: 'three unread responses (repeated participants)' in: [ @@ -78,7 +80,10 @@ describe "ThreadListParticipants", -> new Message(unread: true, from: [@michael]), new Message(unread: true, from: [@evanAgain]), ] - out: [@ben, {spacer: true}, @michael, @evanAgain] + out: [{contact: @ben, unread: false}, + {spacer: true}, + {contact: @michael, unread: true}, + {contact: @evanAgain, unread: true}] },{ name: 'three unread responses' in: [ @@ -87,7 +92,10 @@ describe "ThreadListParticipants", -> new Message(unread: true, from: [@michael]), new Message(unread: true, from: [@kavya]), ] - out: [@ben, {spacer: true}, @michael, @kavya] + out: [{contact: @ben, unread: false}, + {spacer: true}, + {contact: @michael, unread: true}, + {contact: @kavya, unread: true}] },{ name: 'three unread responses to long thread' in: [ @@ -99,7 +107,10 @@ describe "ThreadListParticipants", -> new Message(unread: true, from: [@michael]), new Message(unread: true, from: [@evanAgain]), ] - out: [@ben, {spacer: true}, @michael, @evanAgain] + out: [{contact: @ben, unread: false}, + {spacer: true}, + {contact: @michael, unread: true}, + {contact: @evanAgain, unread: true}] },{ name: 'single unread responses to long thread' in: [ @@ -109,7 +120,10 @@ describe "ThreadListParticipants", -> new Message(unread: false, from: [@ben]), new Message(unread: true, from: [@evanAgain]), ] - out: [@ben, {spacer: true}, @ben, @evanAgain] + out: [{contact: @ben, unread: false}, + {spacer: true}, + {contact: @ben, unread: false}, + {contact: @evanAgain, unread: true}] },{ name: 'long read thread' in: [ @@ -118,7 +132,10 @@ describe "ThreadListParticipants", -> new Message(unread: false, from: [@michael]), new Message(unread: false, from: [@ben]), ] - out: [@ben, {spacer: true}, @michael, @ben] + out: [{contact: @ben, unread: false}, + {spacer: true}, + {contact: @michael, unread: false}, + {contact: @ben, unread: false}] }] for scenario in scenarios @@ -141,23 +158,26 @@ describe "ThreadListParticipants", -> scenarios = [{ name: 'one participant' in: [@ben] - out: [@ben] + out: [{contact: @ben, unread: false}] },{ name: 'one participant (me)' in: [me] - out: [me] + out: [{contact: me, unread: false}] },{ name: 'two participants' in: [@evan, @ben] - out: [@evan, @ben] + out: [{contact: @evan, unread: false}, {contact: @ben, unread: false}] },{ name: 'two participants (me)' in: [@ben, me] - out: [@ben] + out: [{contact: @ben, unread: false}] },{ name: 'lots of participants' in: [@ben, @evan, @michael, @kavya] - out: [@ben, {spacer: true}, @michael, @kavya] + out: [{contact: @ben, unread: false}, + {spacer: true}, + {contact: @michael, unread: false}, + {contact: @kavya, unread: false}] }] for scenario in scenarios diff --git a/internal_packages/thread-list/spec/thread-list-spec.cjsx b/internal_packages/thread-list/spec/thread-list-spec.cjsx index 4224b5434..20525f185 100644 --- a/internal_packages/thread-list/spec/thread-list-spec.cjsx +++ b/internal_packages/thread-list/spec/thread-list-spec.cjsx @@ -216,7 +216,7 @@ describe "ThreadList", -> spyOn(Actions, "archiveCurrentThread") spyOn(Actions, "archiveAndNext") spyOn(Actions, "archiveAndPrevious") - ReactTestUtils.spyOnClass(ThreadList, "_computeColumns").andReturn(columns) + ReactTestUtils.spyOnClass(ThreadList, "_prepareColumns") ThreadStore._resetInstanceVars() @@ -227,6 +227,7 @@ describe "ThreadList", -> @thread_list = ReactTestUtils.renderIntoDocument( ) + @thread_list._columns = columns it "renders into the document", -> expect(ReactTestUtils.isCompositeComponentWithType(@thread_list, @@ -238,7 +239,7 @@ describe "ThreadList", -> expect(@thread_list._onStarThread).toHaveBeenCalled() it "has the expected columns", -> - expect(@thread_list.state.columns).toEqual columns + expect(@thread_list._columns).toEqual columns it "by default has zero children", -> items = ReactTestUtils.scryRenderedComponentsWithType(@thread_list, ListTabular.Item)