@@ -49,7 +49,6 @@ describe('Player API service - merge', () => {
4949 expect ( res . body ) . toStrictEqual ( { message : 'Missing access key scope(s): read:players, write:players' } )
5050 } )
5151
52-
5352 it ( 'should not merge without the write scope' , async ( ) => {
5453 apiKey . scopes = [ APIKeyScope . READ_PLAYERS ]
5554 await ( < EntityManager > app . context . em ) . flush ( )
@@ -64,7 +63,6 @@ describe('Player API service - merge', () => {
6463 expect ( res . body ) . toStrictEqual ( { message : 'Missing access key scope(s): write:players' } )
6564 } )
6665
67-
6866 it ( 'should not merge without the read scope' , async ( ) => {
6967 apiKey . scopes = [ APIKeyScope . WRITE_PLAYERS ]
7068 await ( < EntityManager > app . context . em ) . flush ( )
@@ -183,4 +181,38 @@ describe('Player API service - merge', () => {
183181 }
184182 ] )
185183 } )
184+
185+ it ( 'should not merge players if alias1 does not exist' , async ( ) => {
186+ apiKey . scopes = [ APIKeyScope . READ_PLAYERS , APIKeyScope . WRITE_PLAYERS ]
187+ token = await createToken ( apiKey )
188+
189+ const player2 = await new PlayerFactory ( [ apiKey . game ] ) . one ( )
190+
191+ await ( < EntityManager > app . context . em ) . persistAndFlush ( player2 )
192+
193+ const res = await request ( app . callback ( ) )
194+ . post ( `${ baseUrl } ` )
195+ . send ( { alias1 : 2321 , alias2 : player2 . aliases [ 0 ] . id } )
196+ . auth ( token , { type : 'bearer' } )
197+ . expect ( 404 )
198+
199+ expect ( res . body ) . toStrictEqual ( { message : 'Player with alias 2321 does not exist' } )
200+ } )
201+
202+ it ( 'should not merge players if alias2 does not exist' , async ( ) => {
203+ apiKey . scopes = [ APIKeyScope . READ_PLAYERS , APIKeyScope . WRITE_PLAYERS ]
204+ token = await createToken ( apiKey )
205+
206+ const player1 = await new PlayerFactory ( [ apiKey . game ] ) . one ( )
207+
208+ await ( < EntityManager > app . context . em ) . persistAndFlush ( player1 )
209+
210+ const res = await request ( app . callback ( ) )
211+ . post ( `${ baseUrl } ` )
212+ . send ( { alias1 : player1 . aliases [ 0 ] . id , alias2 : 2456 } )
213+ . auth ( token , { type : 'bearer' } )
214+ . expect ( 404 )
215+
216+ expect ( res . body ) . toStrictEqual ( { message : 'Player with alias 2456 does not exist' } )
217+ } )
186218} )
0 commit comments