diff --git a/src/players/services/players.service.spec.ts b/src/players/services/players.service.spec.ts index c3f1f5532..336b98bf1 100644 --- a/src/players/services/players.service.spec.ts +++ b/src/players/services/players.service.spec.ts @@ -294,7 +294,7 @@ describe('PlayersService', () => { expect(ret.role).toEqual('super-user'); }); - it('should emit the playerRegisters event', async () => new Promise(resolve => { + it('should emit the playerRegisters event', async () => new Promise(resolve => { events.playerRegisters.subscribe(({ player }) => { expect(player).toBeTruthy(); expect(player.steamId).toEqual(mockSteamProfile.id); @@ -416,6 +416,14 @@ describe('PlayersService', () => { expect(ret.name).toEqual('NEW_NAME'); }); + describe('when setting the same name', () => { + it('should not update player name', async () => { + const spy = jest.spyOn(discordService.getAdminsChannel(), 'send'); + await service.updatePlayer(mockPlayer.id, { name: `${mockPlayer.name}` }, admin.id); + expect(spy).not.toHaveBeenCalled(); + }); + }); + it('should update player role', async () => { const ret1 = await service.updatePlayer(mockPlayer.id, { role: 'admin' }, admin.id); expect(ret1.role).toEqual('admin'); diff --git a/src/players/services/players.service.ts b/src/players/services/players.service.ts index 12ed46825..bf8f9c364 100644 --- a/src/players/services/players.service.ts +++ b/src/players/services/players.service.ts @@ -146,7 +146,7 @@ export class PlayersService implements OnModuleInit { const player = await this.getById(playerId); if (player) { - if (update.name) { + if (update.name && player.name !== update.name) { const oldName = player.name; player.name = update.name;