1
+ import { applicationContextForClient as applicationContext } from '../../../../shared/src/business/test/createTestApplicationContext' ;
1
2
import { recentMessagesHelper as recentMessagesHelperComputed } from './recentMessagesHelper' ;
2
3
import { runCompute } from 'cerebral/test' ;
3
4
import { withAppContextDecorator } from '../../withAppContext' ;
@@ -7,6 +8,9 @@ const recentMessagesHelper = withAppContextDecorator(
7
8
) ;
8
9
9
10
describe ( 'recentMessagesHelper' , ( ) => {
11
+ const { STATUS_TYPES , TRIAL_SESSION_SCOPE_TYPES } =
12
+ applicationContext . getConstants ( ) ;
13
+
10
14
it ( 'returns 5 most recent messages' , ( ) => {
11
15
const result = runCompute ( recentMessagesHelper , {
12
16
state : {
@@ -88,4 +92,117 @@ describe('recentMessagesHelper', () => {
88
92
recentMessages : [ ] ,
89
93
} ) ;
90
94
} ) ;
95
+
96
+ it ( 'should set showTrialInformation to true when caseStatus is calendared' , ( ) => {
97
+ const mockCalendaredMessage = {
98
+ caseStatus : STATUS_TYPES . calendared ,
99
+ completedAt : '2019-01-02T16:29:13.122Z' ,
100
+ createdAt : '2019-01-01T16:29:13.122Z' ,
101
+ docketNumber : '101-20' ,
102
+ message : 'This is a test message' ,
103
+ trialDate : '2025-01-01T16:29:13.122Z' ,
104
+ trialLocation : 'Austin, TX' ,
105
+ } ;
106
+ const result = runCompute ( recentMessagesHelper , {
107
+ state : {
108
+ messageBoxToDisplay : {
109
+ box : 'outbox' ,
110
+ } ,
111
+ messages : [ mockCalendaredMessage ] ,
112
+ screenMetadata : { } ,
113
+ user : {
114
+ role : 'adc' ,
115
+ } ,
116
+ } ,
117
+ } ) ;
118
+
119
+ expect ( result . recentMessages [ 0 ] . showTrialInformation ) . toBe ( true ) ;
120
+ } ) ;
121
+
122
+ it ( 'should set showTrialInformation to false when caseStatus is NOT calendared' , ( ) => {
123
+ const mockCalendaredMessage = {
124
+ caseStatus : STATUS_TYPES . new ,
125
+ completedAt : '2019-01-02T16:29:13.122Z' ,
126
+ createdAt : '2019-01-01T16:29:13.122Z' ,
127
+ docketNumber : '101-20' ,
128
+ message : 'This is a test message' ,
129
+ } ;
130
+
131
+ const result = runCompute ( recentMessagesHelper , {
132
+ state : {
133
+ messageBoxToDisplay : {
134
+ box : 'outbox' ,
135
+ } ,
136
+ messages : [ mockCalendaredMessage ] ,
137
+ screenMetadata : { } ,
138
+ user : {
139
+ role : 'adc' ,
140
+ } ,
141
+ } ,
142
+ } ) ;
143
+
144
+ expect ( result . recentMessages [ 0 ] . showTrialInformation ) . toBe ( false ) ;
145
+ } ) ;
146
+
147
+ it ( 'should format the trialDate and trialLocation on the message when caseStatus is Calendared' , ( ) => {
148
+ const mockCalendaredMessage = {
149
+ caseStatus : STATUS_TYPES . calendared ,
150
+ completedAt : '2019-01-02T16:29:13.122Z' ,
151
+ createdAt : '2019-01-01T16:29:13.122Z' ,
152
+ docketNumber : '101-20' ,
153
+ message : 'This is a test message' ,
154
+ trialDate : '2019-01-01T16:29:13.122Z' ,
155
+ trialLocation : 'Houston, Texas' ,
156
+ } ;
157
+
158
+ const result = runCompute ( recentMessagesHelper , {
159
+ state : {
160
+ messageBoxToDisplay : {
161
+ box : 'outbox' ,
162
+ } ,
163
+ messages : [ mockCalendaredMessage ] ,
164
+ screenMetadata : { } ,
165
+ user : {
166
+ role : 'adc' ,
167
+ } ,
168
+ } ,
169
+ } ) ;
170
+
171
+ expect ( result . recentMessages [ 0 ] ) . toMatchObject ( {
172
+ formattedTrialDate : '01/01/19' ,
173
+ formattedTrialLocation : 'Houston, TX' ,
174
+ } ) ;
175
+ } ) ;
176
+
177
+ it ( `should not abbreviate trialLocation when it is ${ TRIAL_SESSION_SCOPE_TYPES . standaloneRemote } ` , ( ) => {
178
+ const mockCalendaredMessage = {
179
+ caseStatus : STATUS_TYPES . calendared ,
180
+ completedAt : '2019-01-02T16:29:13.122Z' ,
181
+ createdAt : '2019-01-01T16:29:13.122Z' ,
182
+ docketNumber : '101-20' ,
183
+ message : 'This is a test message' ,
184
+ trialDate : '2019-01-01T16:29:13.122Z' ,
185
+ trialLocation : TRIAL_SESSION_SCOPE_TYPES . standaloneRemote ,
186
+ } ;
187
+
188
+ const result = runCompute ( recentMessagesHelper , {
189
+ state : {
190
+ messageBoxToDisplay : {
191
+ box : 'outbox' ,
192
+ } ,
193
+ messages : [ mockCalendaredMessage ] ,
194
+ screenMetadata : { } ,
195
+ user : {
196
+ role : 'adc' ,
197
+ } ,
198
+ } ,
199
+ } ) ;
200
+
201
+ expect (
202
+ applicationContext . getUtilities ( ) . abbreviateState ,
203
+ ) . not . toHaveBeenCalled ( ) ;
204
+ expect ( result . recentMessages [ 0 ] ) . toMatchObject ( {
205
+ formattedTrialLocation : TRIAL_SESSION_SCOPE_TYPES . standaloneRemote ,
206
+ } ) ;
207
+ } ) ;
91
208
} ) ;
0 commit comments