'use strict';
const assert = require('assert');
const Event = require('../db/models/Event');


describe('Validation of User records', () => {

  it('should require a name for every event', () => {
    const validationEvt = new Event({ name: undefined }),
          validationResult = validationEvt.validateSync(),
          { message } = validationResult.errors.name;

    assert(message === 'This event requires a name.');
  });

  it ('should require an event\'s name to be at least 3 characters long', () => {
    const validationEvt = new Event({ name: 'ab' }),
          validationResult = validationEvt.validateSync(),
          { message } = validationResult.errors.name;

    assert(message === 'Your event name must be at least 3 characters long.');
  });

  it('should disallow invalid records from being saved to the database', (done) => {
    const invalidEvt = new Event({ name: 'ab', });
    invalidEvt
      .save()
      .catch((validationResult) => {
        const { message } = validationResult.errors.name;

        assert(message === 'Your event name must be at least 3 characters long.');
        done();
      });
  });

});

@@ -136,16 +136,147 @@
 ) =%3E %7B%0A%0A
+  // Tests that records for which no %60name%60 property is defined are marked invalid%0A  //  and return a validation fallback message:%0A
   it('sh
@@ -313,32 +313,32 @@
 event', () =%3E %7B%0A
-
     const valida
@@ -551,24 +551,189 @@
 .');%0A  %7D);%0A%0A
+  // Tests that records for which the %60name%60 property is less than three (3) characters%0A  //  in length are marked invalid and return a validation fallback message:%0A
   it ('shoul
@@ -1055,16 +1055,157 @@
 %0A  %7D);%0A%0A
+  // Tests that attempts to %60save()%60 records marked as invalid to the database are caught%0A  //  as errors and are not added to the database:%0A
   it('sh

Write test to catch invalid inserts