"use strict";

var Reminder = require('./reminder');
var REMINDER_STATUS = require('../../constant/reminder/reminder-status.constant');
var REMINDER_TYPE = require('../../constant/reminder/reminder-type.constant');
describe('Reminder', function () {
  it('should validate reminder', function () {
    var data = {
      _id: '5aea20dd4a66fc0000fff77b',
      createdDate: new Date(),
      label: {
        appName: 'radiation',
        type: 'material'
      },
      campusCode: '03',
      tenantCode: 'UC',
      applicationName: 'Radiation',
      status: REMINDER_STATUS.PENDING,
      type: REMINDER_TYPE.EMAIL,
      details: {
        toRecipients: [{
          email: 'itester@ucdavis.edu'
        }],
        ccRecipients: [],
        bccRecipients: [],
        notification: null,
        templateLabel: 'MATERIAL_ORDER',
        templateParams: {},
        sendDate: new Date()
      }
    };
    var reminder = new Reminder(data);
    expect(reminder.validate().valid).toBeTruthy();
  });
  it('should validate reminder and does not trigger notification immediately', function () {
    var data = {
      _id: '5aea20dd4a66fc0000fff77b',
      createdDate: new Date(),
      label: {
        appName: 'radiation',
        type: 'material'
      },
      campusCode: '03',
      tenantCode: 'UC',
      applicationName: 'Radiation',
      status: REMINDER_STATUS.PENDING,
      type: REMINDER_TYPE.EMAIL,
      details: {
        toRecipients: [{
          email: 'itester@ucdavis.edu'
        }],
        ccRecipients: [],
        bccRecipients: [],
        notification: null,
        templateLabel: 'MATERIAL_ORDER',
        templateParams: {},
        sendDate: new Date()
      }
    };
    var reminder = new Reminder(data);
    expect(reminder.validate().valid).toBeTruthy();
  });
  it('should validate reminder and trigger notification immediately', function () {
    var data = {
      _id: '5bea20de4a66fc0000fff77c',
      createdDate: new Date(),
      label: {
        appName: 'radiation',
        type: 'material'
      },
      campusCode: '03',
      tenantCode: 'UC',
      applicationName: 'Radiation',
      status: REMINDER_STATUS.PENDING,
      type: REMINDER_TYPE.EMAIL,
      details: {
        immediate: true,
        toRecipients: [{
          email: 'itester@ucdavis.edu'
        }],
        ccRecipients: [],
        bccRecipients: [],
        notification: null,
        templateLabel: 'MATERIAL_ORDER',
        templateParams: {},
        sendDate: new Date()
      }
    };
    var reminder = new Reminder(data);
    expect(reminder.validate().valid).toBeTruthy();
  });
});