11import  {  act ,  fireEvent ,  render ,  screen  }  from  '@testing-library/react' ; 
2- import  {  mockGitHubCloudAccount  }  from  '../__mocks__/state-mocks' ; 
2+ import  {  mockGitHubCloudAccount ,  mockSettings  }  from  '../__mocks__/state-mocks' ; 
3+ import  {  AppContext  }  from  '../context/App' ; 
4+ import  {  GroupBy  }  from  '../types' ; 
35import  {  mockGitHubNotifications  }  from  '../utils/api/__mocks__/response-mocks' ; 
46import  *  as  links  from  '../utils/links' ; 
57import  {  AccountNotifications  }  from  './AccountNotifications' ; 
@@ -9,14 +11,37 @@ jest.mock('./RepositoryNotifications', () => ({
911} ) ) ; 
1012
1113describe ( 'components/AccountNotifications.tsx' ,  ( )  =>  { 
12-   it ( 'should render itself (github.com with notifications)' ,  ( )  =>  { 
14+   it ( 'should render itself (github.com with notifications) - group by repositories ' ,  ( )  =>  { 
1315    const  props  =  { 
1416      account : mockGitHubCloudAccount , 
1517      notifications : mockGitHubNotifications , 
1618      showAccountHostname : true , 
1719    } ; 
1820
19-     const  tree  =  render ( < AccountNotifications  { ...props }  /> ) ; 
21+     const  tree  =  render ( 
22+       < AppContext . Provider 
23+         value = { {  settings : {  ...mockSettings ,  groupBy : GroupBy . REPOSITORY  }  } } 
24+       > 
25+         < AccountNotifications  { ...props }  /> 
26+       </ AppContext . Provider > , 
27+     ) ; 
28+     expect ( tree ) . toMatchSnapshot ( ) ; 
29+   } ) ; 
30+ 
31+   it ( 'should render itself (github.com with notifications) - group by date' ,  ( )  =>  { 
32+     const  props  =  { 
33+       account : mockGitHubCloudAccount , 
34+       notifications : mockGitHubNotifications , 
35+       showAccountHostname : true , 
36+     } ; 
37+ 
38+     const  tree  =  render ( 
39+       < AppContext . Provider 
40+         value = { {  settings : {  ...mockSettings ,  groupBy : GroupBy . DATE  }  } } 
41+       > 
42+         < AccountNotifications  { ...props }  /> 
43+       </ AppContext . Provider > , 
44+     ) ; 
2045    expect ( tree ) . toMatchSnapshot ( ) ; 
2146  } ) ; 
2247
@@ -27,7 +52,11 @@ describe('components/AccountNotifications.tsx', () => {
2752      showAccountHostname : true , 
2853    } ; 
2954
30-     const  tree  =  render ( < AccountNotifications  { ...props }  /> ) ; 
55+     const  tree  =  render ( 
56+       < AppContext . Provider  value = { {  settings : mockSettings  } } > 
57+         < AccountNotifications  { ...props }  /> 
58+       </ AppContext . Provider > , 
59+     ) ; 
3160    expect ( tree ) . toMatchSnapshot ( ) ; 
3261  } ) ; 
3362
@@ -41,7 +70,11 @@ describe('components/AccountNotifications.tsx', () => {
4170    } ; 
4271
4372    await  act ( async  ( )  =>  { 
44-       render ( < AccountNotifications  { ...props }  /> ) ; 
73+       render ( 
74+         < AppContext . Provider  value = { {  settings : mockSettings  } } > 
75+           < AccountNotifications  { ...props }  /> 
76+         </ AppContext . Provider > , 
77+       ) ; 
4578    } ) ; 
4679
4780    fireEvent . click ( screen . getByTitle ( 'Open Profile' ) ) ; 
@@ -58,12 +91,20 @@ describe('components/AccountNotifications.tsx', () => {
5891    } ; 
5992
6093    await  act ( async  ( )  =>  { 
61-       render ( < AccountNotifications  { ...props }  /> ) ; 
94+       render ( 
95+         < AppContext . Provider  value = { {  settings : mockSettings  } } > 
96+           < AccountNotifications  { ...props }  /> 
97+         </ AppContext . Provider > , 
98+       ) ; 
6299    } ) ; 
63100
64101    fireEvent . click ( screen . getByTitle ( 'Hide account notifications' ) ) ; 
65102
66-     const  tree  =  render ( < AccountNotifications  { ...props }  /> ) ; 
103+     const  tree  =  render ( 
104+       < AppContext . Provider  value = { {  settings : mockSettings  } } > 
105+         < AccountNotifications  { ...props }  /> 
106+       </ AppContext . Provider > , 
107+     ) ; 
67108    expect ( tree ) . toMatchSnapshot ( ) ; 
68109  } ) ; 
69110} ) ; 
0 commit comments