Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#167727627 Set up Sign Up Validations #26

Merged
merged 1 commit into from
Aug 23, 2019

Conversation

ChidozieGabriel
Copy link
Collaborator

What does this PR do?

Set up sign up validations

Description of Task to be completed?

Return error with status code of 400 when user signs up with:

  • Already existing email address
  • An invalid email address
  • A password of length less than 8
  • A non-alphanumeric password

How should this be manually tested?

  • Clone the repo and cd into the project directory
  • Run yarn install to install the project's dependency
  • Run yarn test to start the app

What are the relevant pivotal tracker stories?

#167727627

@ChidozieGabriel ChidozieGabriel added the W.I.P The PR is still being worked on label Aug 21, 2019
src/seeders/20190821181501-demo-user.js Outdated Show resolved Hide resolved
src/seeders/20190821181501-demo-user.js Outdated Show resolved Hide resolved
src/models/index.js Outdated Show resolved Hide resolved
src/models/index.js Outdated Show resolved Hide resolved
src/models/index.js Outdated Show resolved Hide resolved
src/controllers/UserController.js Outdated Show resolved Hide resolved
src/controllers/UserController.js Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package.json Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
@ChidozieGabriel ChidozieGabriel added Ready-for-review The PR is ready to be reviewed by teammates and removed W.I.P The PR is still being worked on labels Aug 21, 2019
@ChidozieGabriel ChidozieGabriel force-pushed the ft-signup-validation-167727627 branch 2 times, most recently from f3ba926 to 9e84f5e Compare August 22, 2019 09:50
src/models/User.js Outdated Show resolved Hide resolved
src/models/User.js Outdated Show resolved Hide resolved
src/models/User.js Outdated Show resolved Hide resolved
src/models/User.js Outdated Show resolved Hide resolved
src/models/index.js Outdated Show resolved Hide resolved
src/models/index.js Outdated Show resolved Hide resolved
src/models/index.js Outdated Show resolved Hide resolved
src/models/index.js Outdated Show resolved Hide resolved
src/test/integrationTest/authRoute.test.js Outdated Show resolved Hide resolved
src/test/integrationTest/authRoute.test.js Outdated Show resolved Hide resolved
src/test/integrationTest/authRoute.test.js Outdated Show resolved Hide resolved
it('should throw error 400 when user signs up with a null email and null password', (done) => {
runTest(done);
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you would need to re-write your tests because I don't understand the tests you wrote.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since all my tests are the same code, instead of repeating it, I encapsulated it in a function.
Line 37

const runTest = (done, object = {}) => {
  chai
    .request(server)
    .post(route)
    .send(object)
    .then(res => {
      expect(res).to.have.status(400);
      const { body } = res;
      expect(body).to.be.an('object');
      expect(body).to.have.property('error');
      const { status } = body;
      expect(status).to.eql(res.status);
      done();
    })
    .catch(done);
};

@ChidozieGabriel ChidozieGabriel force-pushed the ft-signup-validation-167727627 branch 2 times, most recently from 4e5bdfb to 97f9b0a Compare August 23, 2019 07:56
src/seeders/20190823074623-demo-user.js Outdated Show resolved Hide resolved
src/seeders/20190823074623-demo-user.js Outdated Show resolved Hide resolved
runTest(done, nullPassword);
});

it('should throw error 400 when user signs up with a null email and null password', done => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 79 exceeds the maximum line length of 80 max-len

runTest(done, nonAlphaNumPassword);
});

it('should throw error 400 when user signs up with an invalid email', done => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 67 exceeds the maximum line length of 80 max-len

runTest(done, shortPassword);
});

it('should throw error 400 when user signs up with a non-alphanumeric password', done => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 63 exceeds the maximum line length of 80 max-len

runTest(done, validUser);
});

it('should throw error 400 when user signs up with a short password', done => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 59 exceeds the maximum line length of 80 max-len

fs.readdirSync(__dirname)
.filter(
file => file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected newline before ')' function-paren-newline

.forEach((file) => {
fs.readdirSync(__dirname)
.filter(
file => file.indexOf('.') !== 0 && file !== basename && file.slice(-3) === '.js'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 23 exceeds the maximum line length of 80 max-len

.filter((file) => (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js'))
.forEach((file) => {
fs.readdirSync(__dirname)
.filter(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected newline after '(' function-paren-newline

},
{
classMethods: {
associate: (models) => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unexpected parentheses around single function argument arrow-parens

@Daymorelah Daymorelah merged commit ff5c6ac into develop Aug 23, 2019
NonsoAmadi10 pushed a commit that referenced this pull request Aug 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready-for-review The PR is ready to be reviewed by teammates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants