Step 9: Test users route

Let's update the corresponding tests in users.test.js to account for changes we made to users.js in the previous step.

Everywhere we create a user, we must pass the password! Example:

const name = faker.name.fullName();
const email = faker.internet.email();
const password = faker.internet.password(6);
const response = await request.post(endpoint).send({
  name,
  email,
  password
});

Everywhere we expect user data in the response, we should make sure password is not returned! Example:

expect(response.body.data.password).toBeUndefined();

Everywhere we can pass a password, we must check that it throws error for invalid ones. Example:

it("Short password", async () => {
  const name = faker.name.fullName();
  const email = faker.internet.email();
  const password = faker.internet.password(5);
  const response = await request.post(endpoint).send({
    name,
    email,
    password
  });
  expect(response.status).toBe(400);
});

Refer to the commit history to see the changes made at this step.