{"size": 3026, "ext": "js", "max_stars_repo_path": "app/imports/api/verification/VerificationRequestCollection.test.js", "max_stars_repo_name": "SantoshSrinivas79/radgrad", "max_stars_repo_stars_event_min_datetime": "2016-10-24T05:23:29.000Z", "max_stars_repo_stars_event_max_datetime": "2020-11-09T19:22:17.000Z", "max_issues_repo_path": "app/imports/api/verification/VerificationRequestCollection.test.js", "max_issues_repo_name": "SantoshSrinivas79/radgrad", "max_issues_repo_issues_event_min_datetime": "2015-11-10T16:02:47.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T18:20:16.000Z", "max_forks_repo_path": "app/imports/api/verification/VerificationRequestCollection.test.js", "max_forks_repo_name": "SantoshSrinivas79/radgrad", "max_forks_repo_forks_event_min_datetime": "2016-10-24T03:45:36.000Z", "max_forks_repo_forks_event_max_datetime": "2021-04-08T18:27:53.000Z"}
{"max_stars_count": 12, "max_issues_count": 360, "max_forks_count": 7, "avg_line_length": 48.8064516129, "max_line_length": 106, "alphanum_fraction": 0.7217448777}
import { Meteor } from 'meteor/meteor';
import { expect } from 'chai';
import { ROLE } from '../role/Role';
import { VerificationRequests } from './VerificationRequestCollection.js';
import { Semesters } from '../semester/SemesterCollection';
import { OpportunityInstances } from '../opportunity/OpportunityInstanceCollection';
import { removeAllEntities } from '../base/BaseUtilities';
import { makeSampleOpportunityInstance, makeSampleOpportunity } from '../opportunity/SampleOpportunities';
import { makeSampleUser } from '../user/SampleUsers';

/* eslint prefer-arrow-callback: "off", no-unused-expressions: "off" */
/* eslint-env mocha */

if (Meteor.isServer) {
  describe('VerificationRequestCollection', function testSuite() {
    before(function setup() {
      removeAllEntities();
    });

    after(function teardown() {
      removeAllEntities();
    });

    it('#define, #isDefined, #removeIt, #findOne, #toString, #dumpOne, #restoreOne', function test() {
      Semesters.define({ term: Semesters.SUMMER, year: 2015 });
      Semesters.define({ term: Semesters.FALL, year: 2015 });
      const student = makeSampleUser();
      const faculty = makeSampleUser(ROLE.FACULTY);
      const opportunityInstance = makeSampleOpportunityInstance(student, faculty);
      let docID = VerificationRequests.define({ student, opportunityInstance });
      expect(VerificationRequests.isDefined(docID)).to.be.true;
      expect(VerificationRequests.findOne({ opportunityInstanceID: opportunityInstance })).to.exist;
      expect(VerificationRequests.findDoc(docID).documentation).to.equal('None');
      VerificationRequests.toString(docID);
      let dumpObject = VerificationRequests.dumpOne(docID);
      expect(dumpObject.retired).to.be.undefined;
      expect(VerificationRequests.findNonRetired().length).to.equal(1);
      VerificationRequests.update(docID, { retired: true });
      expect(VerificationRequests.findNonRetired().length).to.equal(0);
      VerificationRequests.removeIt(docID);
      expect(VerificationRequests.isDefined(docID)).to.be.false;
      docID = VerificationRequests.restoreOne(dumpObject);
      expect(VerificationRequests.isDefined(docID)).to.be.true;
      VerificationRequests.update(docID, { retired: true });
      dumpObject = VerificationRequests.dumpOne(docID);
      expect(dumpObject.retired).to.be.true;
      expect(VerificationRequests.findNonRetired().length).to.equal(0);
      VerificationRequests.removeIt(docID);
    });

    it('#define using semester and opportunity', function test() {
      const semester = Semesters.define({ term: Semesters.SUMMER, year: 2015 });
      const opportunity = makeSampleOpportunity(makeSampleUser(ROLE.FACULTY));
      const student = makeSampleUser();
      OpportunityInstances.define({ semester, opportunity, student });
      const docID = VerificationRequests.define({ student, semester, opportunity });
      expect(VerificationRequests.isDefined(docID)).to.be.true;
      VerificationRequests.removeIt(docID);
    });
  });
}
