1
1
import * as React from 'react' ;
2
2
import { mount , shallow } from 'enzyme' ;
3
3
import cloneDeep from 'lodash/cloneDeep' ;
4
+ import { FormattedMessage } from 'react-intl' ;
4
5
5
6
import { FEED_ITEM_TYPE_TASK } from '../../../../../constants' ;
6
7
import { TaskComponent as Task } from '..' ;
@@ -18,6 +19,7 @@ const allHandlers = {
18
19
const approverSelectorContacts = [ ] ;
19
20
20
21
describe ( 'elements/content-sidebar/ActivityFeed/task-new/Task' , ( ) => {
22
+ const placeholderUser = { nam : '' , id : '0' , type : 'user' } ;
21
23
const currentUser = { name : 'Jake Thomas' , id : '1' , type : 'user' } ;
22
24
const otherUser = { name : 'Patrick Paul' , id : '3' , type : 'user' } ;
23
25
const creatorUser = { name : 'Steven Yang' , id : '5' , type : 'user' } ;
@@ -144,6 +146,22 @@ describe('elements/content-sidebar/ActivityFeed/task-new/Task', () => {
144
146
expect ( wrapper . find ( '[data-testid="task-due-date"]' ) ) . toHaveLength ( 1 ) ;
145
147
} ) ;
146
148
149
+ test ( 'should show prior collaborator text if created_by user is a placeholder user' , ( ) => {
150
+ const completeWrapper = mount (
151
+ < Task
152
+ { ...task }
153
+ created_by = { placeholderUser }
154
+ currentUser = { currentUser }
155
+ onEdit = { jest . fn ( ) }
156
+ onDelete = { jest . fn ( ) }
157
+ due_at = { new Date ( ) - 1000 }
158
+ status = "COMPLETED"
159
+ /> ,
160
+ ) ;
161
+ const headline = completeWrapper . find ( '.bcs-Task-headline' ) ;
162
+ expect ( headline . find ( FormattedMessage ) . prop ( 'id' ) ) . toBe ( 'be.priorCollaborator' ) ;
163
+ } ) ;
164
+
147
165
test ( 'due date should have overdue class if task is incomplete and due date is in past' , ( ) => {
148
166
const incompleteWrapper = mount (
149
167
< Task
@@ -270,10 +288,7 @@ describe('elements/content-sidebar/ActivityFeed/task-new/Task', () => {
270
288
test ( 'should call onView when view-task-details button is clicked for multifile task' , ( ) => {
271
289
const onViewSpy = jest . fn ( ) ;
272
290
const wrapper = mount ( < Task { ...taskMultifile } currentUser = { currentUser } onView = { onViewSpy } /> ) ;
273
- wrapper
274
- . find ( '[data-testid="view-task"]' )
275
- . hostNodes ( )
276
- . simulate ( 'click' ) ;
291
+ wrapper . find ( '[data-testid="view-task"]' ) . hostNodes ( ) . simulate ( 'click' ) ;
277
292
expect ( onViewSpy ) . toHaveBeenCalledWith ( taskId , false ) ;
278
293
} ) ;
279
294
0 commit comments