@@ -17,8 +17,8 @@ describe('OnyxDerived', () => {
17
17
initOnyxDerivedValues ( ) ;
18
18
} ) ;
19
19
20
- beforeEach ( ( ) => {
21
- Onyx . clear ( ) ;
20
+ beforeEach ( async ( ) => {
21
+ await Onyx . clear ( ) ;
22
22
} ) ;
23
23
24
24
describe ( 'conciergeChatReportID' , ( ) => {
@@ -33,55 +33,55 @@ describe('OnyxDerived', () => {
33
33
34
34
describe ( 'reportAttributes' , ( ) => {
35
35
const mockReport = {
36
- reportID : '123' ,
36
+ reportID : `test_1` ,
37
37
reportName : 'Test Report' ,
38
38
type : 'chat' ,
39
-
39
+ chatType : CONST . REPORT . CHAT_TYPE . POLICY_ROOM ,
40
+ lastVisibleActionCreated : '2023-01-01T00:00:00.000Z' ,
41
+ lastMessageText : 'Test message' ,
42
+ lastActorAccountID : 1 ,
43
+ lastMessageHtml : '<p>Test message</p>' ,
44
+ policyID : '123' ,
45
+ ownerAccountID : 1 ,
46
+ stateNum : CONST . REPORT . STATE_NUM . OPEN ,
47
+ statusNum : CONST . REPORT . STATUS_NUM . OPEN ,
40
48
} ;
41
49
42
- const mockReports = {
43
- [ mockReport . reportID ] : mockReport ,
44
- } ;
45
-
46
- it ( 'returns empty reports when dependencies are not set' , ( ) => {
47
- waitForBatchedUpdates ( ) . then ( async ( ) => {
48
- const derivedReportAttributes = await OnyxUtils . get ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES ) ;
49
- expect ( derivedReportAttributes ) . toEqual ( {
50
- reports : { } ,
51
- locale : null ,
52
- } ) ;
50
+ it ( 'returns empty reports when dependencies are not set' , async ( ) => {
51
+ await waitForBatchedUpdates ( ) ;
52
+ const derivedReportAttributes = await OnyxUtils . get ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES ) ;
53
+ expect ( derivedReportAttributes ) . toMatchObject ( {
54
+ reports : { } ,
53
55
} ) ;
54
56
} ) ;
55
57
56
- it ( 'computes report attributes when reports are set' , ( ) => {
57
- waitForBatchedUpdates ( ) . then ( async ( ) => {
58
- await Onyx . set ( ONYXKEYS . COLLECTION . REPORT , mockReports ) ;
59
- await Onyx . set ( ONYXKEYS . NVP_PREFERRED_LOCALE , 'en' ) ;
60
- const derivedReportAttributes = await OnyxUtils . get ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES ) ;
61
- expect ( derivedReportAttributes ) . toEqual ( {
62
- reports : {
63
- [ mockReport . reportID ] : {
64
- reportName : expect ( String ) ,
65
- } ,
58
+ it ( 'computes report attributes when reports are set' , async ( ) => {
59
+ await waitForBatchedUpdates ( ) ;
60
+
61
+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ mockReport . reportID } ` , mockReport ) ;
62
+ await Onyx . set ( ONYXKEYS . NVP_PREFERRED_LOCALE , 'en' ) ;
63
+
64
+ const derivedReportAttributes = await OnyxUtils . get ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES ) ;
65
+
66
+ expect ( derivedReportAttributes ) . toMatchObject ( {
67
+ reports : {
68
+ [ mockReport . reportID ] : {
69
+ reportName : mockReport . reportName ,
66
70
} ,
67
- locale : 'en' ,
68
- } ) ;
71
+ } ,
69
72
} ) ;
70
73
} ) ;
71
74
72
- it ( 'updates when locale changes' , ( ) => {
73
- waitForBatchedUpdates ( ) . then ( async ( ) => {
74
- await Onyx . set ( ONYXKEYS . COLLECTION . REPORT , mockReports ) ;
75
- await Onyx . set ( ONYXKEYS . NVP_PREFERRED_LOCALE , 'es' ) ;
76
- const derivedReportAttributes = await OnyxUtils . get ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES ) ;
77
- expect ( derivedReportAttributes ) . toEqual ( {
78
- reports : {
79
- [ mockReport . reportID ] : {
80
- reportName : expect ( String ) ,
81
- } ,
82
- } ,
83
- locale : 'es' ,
84
- } ) ;
75
+ it ( 'updates when locale changes' , async ( ) => {
76
+ await waitForBatchedUpdates ( ) ;
77
+
78
+ await Onyx . set ( `${ ONYXKEYS . COLLECTION . REPORT } ${ mockReport . reportID } ` , mockReport ) ;
79
+ await Onyx . set ( ONYXKEYS . NVP_PREFERRED_LOCALE , 'es' ) ;
80
+
81
+ const derivedReportAttributes = await OnyxUtils . get ( ONYXKEYS . DERIVED . REPORT_ATTRIBUTES ) ;
82
+
83
+ expect ( derivedReportAttributes ) . toMatchObject ( {
84
+ locale : 'es' ,
85
85
} ) ;
86
86
} ) ;
87
87
} ) ;
0 commit comments