@@ -5,6 +5,7 @@ import createUserAndToken from '../../../utils/createUserAndToken'
55import UserTwoFactorAuth from '../../../../src/entities/user-two-factor-auth'
66import User from '../../../../src/entities/user'
77import generateRecoveryCodes from '../../../../src/lib/auth/generateRecoveryCodes'
8+ import createOrganisationAndGame from '../../../utils/createOrganisationAndGame'
89
910async function setTwoFactorAuthSession ( user : User ) {
1011 await redis . set ( `2fa:${ user . id } ` , 'true' )
@@ -15,9 +16,10 @@ async function removeTwoFactorAuthSession(user: User) {
1516}
1617
1718async function createUserWithTwoFactorAuth ( em : EntityManager ) : Promise < [ string , User ] > {
19+ const [ organisation ] = await createOrganisationAndGame ( )
1820 const [ token , user ] = await createUserAndToken ( {
1921 twoFactorAuth : new UserTwoFactorAuth ( 'blah' )
20- } )
22+ } , organisation )
2123
2224 user . twoFactorAuth ! . enabled = true
2325 user . recoveryCodes = new Collection < UserRecoveryCode > ( user , generateRecoveryCodes ( user ) )
@@ -39,7 +41,7 @@ describe('User public service - use recovery code', () => {
3941
4042 expect ( res . body . user ) . toBeTruthy ( )
4143 expect ( res . body . user . organisation ) . toBeTruthy ( )
42- expect ( res . body . user . organisation . games ) . toEqual ( [ ] )
44+ expect ( res . body . user . organisation . games ) . toHaveLength ( 1 )
4345
4446 expect ( res . body . accessToken ) . toBeTruthy ( )
4547 expect ( res . body . newRecoveryCodes ) . toBeUndefined ( )
0 commit comments