Source

api/career/SampleCareerGoals.ts

import faker from 'faker';
import moment from 'moment';
import _ from 'lodash';
import { CareerGoals } from './CareerGoalCollection';
import { makeSampleInterest } from '../interest/SampleInterests';
import slugify, { Slugs } from '../slug/SlugCollection';

/**
 * Defines a sample CareerGoal.
 * @return {string} the id of the defined CareerGoal.
 */
export function makeSampleCareerGoal(): string {
  const name = faker.lorem.word();
  const slug = slugify(`career-goal-${name}-${moment().format('YYYY-MM-DD-HH-mm-ss-SSSSS')}`);
  const description = faker.lorem.paragraph();
  const interests = [makeSampleInterest()];
  return CareerGoals.define({ name, slug, description, interests });
}

/**
 * Returns an array of defined CareerGoal ids.
 * @param num the number of CareerGoals to define.
 * @return {string[]} An array of CareerGoal ids.
 */
export function makeSampleCareerGoalArray(num = 2) {
  const retVal = [];
  for (let i = 0; i < num; i++) {
    retVal.push(makeSampleCareerGoal());
  }
  return retVal;
}

/**
 * Returns an array of defined CareerGoal slugs.
 * @param num the number of CareerGoals to define.
 * @return {string[]} An array of defined CareerGoal slugs.
 */
export function makeSampleCareerGoalSlugArray(num = 2) {
  const ids = makeSampleCareerGoalArray(num);
  return _.map(ids, (id) => {
    const doc = CareerGoals.findDoc(id);
    return Slugs.getNameFromID(doc.slugID);
  });
}