11import LoggedInUser from '../LoggedInUser' ;
22
33// Define some test collectives
4- const randomCollective = { id : 1 , type : 'COLLECTIVE' , slug : 'random-collective' } ;
5- const backedCollective = { id : 2 , type : 'COLLECTIVE' , slug : 'backed-collective' } ;
6- const adminCollective = { id : 3 , type : 'COLLECTIVE' , slug : 'admin-collective' } ;
7- const memberCollective = { id : 4 , type : 'COLLECTIVE' , slug : 'member-collective' } ;
8- const hostAdmin = { id : 5 , type : 'ORGANIZATION' , slug : 'admin-host' , isHost : true } ;
9- const hostAdminCollective = { id : 6 , type : 'COLLECTIVE' , slug : 'admin-host-collective' , host : hostAdmin } ;
10- const hostedCollective = { id : 7 , type : 'COLLECTIVE' , slug : 'hosted-collective' } ;
4+ const randomCollective = { legacyId : 1 , type : 'COLLECTIVE' , slug : 'random-collective' } ;
5+ const backedCollective = { legacyId : 2 , type : 'COLLECTIVE' , slug : 'backed-collective' } ;
6+ const adminCollective = { legacyId : 3 , type : 'COLLECTIVE' , slug : 'admin-collective' } ;
7+ const memberCollective = { legacyId : 4 , type : 'COLLECTIVE' , slug : 'member-collective' } ;
8+ const hostAdmin = { legacyId : 5 , type : 'ORGANIZATION' , slug : 'admin-host' , isHost : true } ;
9+ const hostAdminCollective = { legacyId : 6 , type : 'COLLECTIVE' , slug : 'admin-host-collective' , host : hostAdmin } ;
10+ const hostedCollective = { legacyId : 7 , type : 'COLLECTIVE' , slug : 'hosted-collective' } ;
1111const randomEventCollective = {
12- id : 15 ,
12+ legacyId : 15 ,
1313 type : 'EVENT' ,
1414 slug : 'random-event-collective' ,
1515 parentCollective : randomCollective ,
1616} ;
1717const adminEventCollective = {
18- id : 16 ,
18+ legacyId : 16 ,
1919 type : 'EVENT' ,
2020 slug : 'admin-event-collective' ,
2121 parentCollective : randomCollective ,
2222} ;
2323const adminEventCollectiveParent = {
24- id : 17 ,
24+ legacyId : 17 ,
2525 type : 'EVENT' ,
2626 slug : 'admin-event-collective-parent' ,
2727 parentCollective : adminCollective ,
2828} ;
2929
3030const testUser = new LoggedInUser ( {
31- id : 2 ,
32- memberOf : [
33- { collective : backedCollective , role : 'BACKER' } ,
34- { collective : adminCollective , role : 'ADMIN' } ,
35- { collective : memberCollective , role : 'MEMBER' } ,
36- { collective : adminEventCollective , role : 'ADMIN' } ,
37- { collective : hostAdmin , role : 'ADMIN' } ,
38- { collective : hostedCollective , role : 'HOST' } ,
39- ] ,
40- CollectiveId : 1000 ,
41- collective : {
42- id : 1000 ,
43- slug : 'test-user-collective' ,
31+ legacyId : 1000 ,
32+ slug : 'test-user-collective' ,
33+ memberOf : {
34+ nodes : [
35+ { account : backedCollective , role : 'BACKER' } ,
36+ { account : adminCollective , role : 'ADMIN' } ,
37+ { account : memberCollective , role : 'MEMBER' } ,
38+ { account : adminEventCollective , role : 'ADMIN' } ,
39+ { account : hostAdmin , role : 'ADMIN' } ,
40+ { account : hostedCollective , role : 'HOST' } ,
41+ ] ,
42+ } ,
43+ workspaces : {
44+ nodes : [
45+ { account : adminCollective , role : 'ADMIN' } ,
46+ { account : adminEventCollective , role : 'ADMIN' } ,
47+ { account : hostAdmin , role : 'ADMIN' } ,
48+ ] ,
4449 } ,
4550} ) ;
4651
@@ -89,7 +94,7 @@ describe('Collectives', () => {
8994 expect ( testUser . isAdminOfCollectiveOrHost ( adminCollective ) ) . toBe ( true ) ;
9095 expect ( testUser . isAdminOfCollectiveOrHost ( adminEventCollective ) ) . toBe ( true ) ;
9196 expect ( testUser . isAdminOfCollectiveOrHost ( adminEventCollectiveParent ) ) . toBe ( true ) ;
92- expect ( testUser . isAdminOfCollectiveOrHost ( testUser . collective ) ) . toBe ( true ) ;
97+ expect ( testUser . isAdminOfCollectiveOrHost ( testUser ) ) . toBe ( true ) ;
9398 } ) ;
9499 } ) ;
95100
@@ -104,7 +109,7 @@ describe('Collectives', () => {
104109 expect ( testUser . isAdminOfCollective ( adminCollective ) ) . toBe ( true ) ;
105110 expect ( testUser . isAdminOfCollective ( adminEventCollective ) ) . toBe ( true ) ;
106111 expect ( testUser . isAdminOfCollective ( adminEventCollectiveParent ) ) . toBe ( true ) ;
107- expect ( testUser . isAdminOfCollective ( testUser . collective ) ) . toBe ( true ) ;
112+ expect ( testUser . isAdminOfCollective ( testUser ) ) . toBe ( true ) ;
108113 } ) ;
109114 } ) ;
110115} ) ;
@@ -131,7 +136,7 @@ describe('Comments', () => {
131136
132137 expect ( testUser . canEditComment ( { account : adminCollective } ) ) . toBe ( true ) ;
133138 expect ( testUser . canEditComment ( { account : adminEventCollective } ) ) . toBe ( true ) ;
134- expect ( testUser . canEditComment ( { account : randomCollective , fromAccount : testUser . collective } ) ) . toBe ( true ) ;
139+ expect ( testUser . canEditComment ( { account : randomCollective , fromAccount : testUser } ) ) . toBe ( true ) ;
135140 expect ( testUser . canEditComment ( { account : adminEventCollectiveParent } ) ) . toBe ( true ) ;
136141 } ) ;
137142 } ) ;
0 commit comments