Skip to content

Commit ee592f7

Browse files
committed
additional tests for missing query params
1 parent 74799cd commit ee592f7

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

tests/services/_api/player-api/identify.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,24 @@ describe('Player API service - identify', () => {
125125
expect(res.body).toStrictEqual({ message: 'Player not found: Talo aliases must be created using the /v1/players/auth API' })
126126
})
127127

128+
it('should require the service to be set', async () => {
129+
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS])
130+
const player = await new PlayerFactory([apiKey.game]).one()
131+
await (<EntityManager>global.em).persistAndFlush(player)
132+
133+
const res = await request(global.app)
134+
.get('/v1/players/identify')
135+
.query({ identifier: player.aliases[0].identifier })
136+
.auth(token, { type: 'bearer' })
137+
.expect(400)
138+
139+
expect(res.body).toStrictEqual({
140+
errors: {
141+
service: ['service is missing from the request query']
142+
}
143+
})
144+
})
145+
128146
it('should require the service to be a non-empty string', async () => {
129147
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS])
130148
const player = await new PlayerFactory([apiKey.game]).one()
@@ -143,6 +161,24 @@ describe('Player API service - identify', () => {
143161
})
144162
})
145163

164+
it('should require the identifier to be set', async () => {
165+
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS])
166+
const player = await new PlayerFactory([apiKey.game]).one()
167+
await (<EntityManager>global.em).persistAndFlush(player)
168+
169+
const res = await request(global.app)
170+
.get('/v1/players/identify')
171+
.query({ service: player.aliases[0].service })
172+
.auth(token, { type: 'bearer' })
173+
.expect(400)
174+
175+
expect(res.body).toStrictEqual({
176+
errors: {
177+
identifier: ['identifier is missing from the request query']
178+
}
179+
})
180+
})
181+
146182
it('should require the identifier to be a non-empty string', async () => {
147183
const [apiKey, token] = await createAPIKeyAndToken([APIKeyScope.READ_PLAYERS])
148184
const player = await new PlayerFactory([apiKey.game]).one()

0 commit comments

Comments
 (0)