const chai = require('chai');
const models = require('../../../repositories/models');

const expect = chai.expect;

const mock = {
  fishId: 'fishId',
  email: 'test@mail.com',
  photo: 'path',
  date: new Date()
};

describe('/repositories/models/photo', () => {
  it('should be valid', () => {
    var valid = new models.photo({
      fishId: mock.fishId,
      email: mock.email,
      photo: mock.photo,
      date: mock.date
    }).validateSync();
    expect(valid).to.be.undefined;

    valid = new models.photo({
      fishId: mock.fishId,
      email: mock.email,
      photo: mock.photo
    }).validateSync();
    expect(valid).to.be.undefined;
  });

  it('should receive fishId error', () => {
    var valid = new models.photo({
      fishId: null,
      email: mock.email,
      photo: mock.photo,
      date: mock.date
    }).validateSync();
    expect(valid.errors.fishId.kind).to.equal('required');
  });

  it('should receive email error', () => {
    var valid = new models.photo({
      fishId: mock.fishId,
      email: null,
      photo: mock.photo,
      date: mock.date
    }).validateSync();
    expect(valid.errors.email.kind).to.equal('required');

    valid = new models.photo({
      fishId: mock.fishId,
      email: 'email',
      photo: mock.photo,
      date: mock.date
    }).validateSync();
    expect(valid.errors.email.kind).to.equal('regexp');
  });

  it('should receive photo error', () => {
    var valid = new models.photo({
      fishId: mock.fishId,
      email: mock.email,
      photo: null,
      date: mock.date
    }).validateSync();
    expect(valid.errors.photo.kind).to.equal('required');
  });
});
