test: Add case to getUser to not return user password

This commit is contained in:
Faruk AYDIN
2023-10-04 20:45:55 +02:00
parent 1683c5630a
commit bd497af89b

View File

@@ -101,6 +101,25 @@ describe('getUser', () => {
expect(response.body).toEqual(expectedResponsePayload);
});
it('should not return user password for a valid user id', async () => {
const query = `
query {
getUser(id: "${anotherUser.id}") {
id
email
password
}
}
`;
const response = await requestObject.send({ query }).expect(400);
expect(response.body.errors).toBeDefined();
expect(response.body.errors[0].message).toEqual(
'Cannot query field "password" on type "User".'
);
});
it('should return not found for invalid user id', async () => {
const invalidUserId = Crypto.randomUUID();