Skip to content

Commit

Permalink
additional tests for missing query params
Browse files Browse the repository at this point in the history
  • Loading branch information
tudddorrr committed Oct 14, 2024
1 parent 74799cd commit ee592f7
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/services/_api/player-api/identify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,24 @@ describe('Player API service - identify', () => {
expect(res.body).toStrictEqual({ message: 'Player not found: Talo aliases must be created using the /v1/players/auth API' })
})

it('should require the service to be set', async () => {
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS])
const player = await new PlayerFactory([apiKey.game]).one()
await (<EntityManager>global.em).persistAndFlush(player)

const res = await request(global.app)
.get('/v1/players/identify')
.query({ identifier: player.aliases[0].identifier })
.auth(token, { type: 'bearer' })
.expect(400)

expect(res.body).toStrictEqual({
errors: {
service: ['service is missing from the request query']
}
})
})

it('should require the service to be a non-empty string', async () => {
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS])
const player = await new PlayerFactory([apiKey.game]).one()
Expand All @@ -143,6 +161,24 @@ describe('Player API service - identify', () => {
})
})

it('should require the identifier to be set', async () => {
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS])
const player = await new PlayerFactory([apiKey.game]).one()
await (<EntityManager>global.em).persistAndFlush(player)

const res = await request(global.app)
.get('/v1/players/identify')
.query({ service: player.aliases[0].service })
.auth(token, { type: 'bearer' })
.expect(400)

expect(res.body).toStrictEqual({
errors: {
identifier: ['identifier is missing from the request query']
}
})
})

it('should require the identifier to be a non-empty string', async () => {
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS])
const player = await new PlayerFactory([apiKey.game]).one()
Expand Down

0 comments on commit ee592f7

Please sign in to comment.