<commit_before>moment = require 'moment'

describe 'Api.referrer/Api.referrral', ->
  user = null
  referredUser = null
  refrFixture = null
  reflFixture = null
  referrer = null
  referral = null

  program =
    name: 'Sample Program'
    triggers: [0]
    actions: [
      {
        type:       'credit'
        amount:     1
        currency:   'points'
      }
    ]

  before ->
    user = yield api.account.create
      firstName:       firstName
      lastName:        lastName
      email:           email
      password:        <PASSWORD>
      passwordConfirm: <PASSWORD>

    referredUser = yield api.account.create
      firstName:       'referred' + firstName
      lastName:        'referred' + lastName
      email:           'referred' + email
      password:        <PASSWORD>
      passwordConfirm: <PASSWORD>

    refrFixture =
      userId: user.id
      orderId: 'orderId'
      program: program

    referrer = yield api.referrer.create refrFixture

    reflFixture =
      referrerId: referrer.id
      referrerUserId: user.id
      userId: referredUser.id
      orderId: 'referredOrderId'

    referral = yield api.referral.create reflFixture

  describe '.list referrer', ->
    it 'should list referrers', ->
      {count, models} = yield api.referrer.list()<commit_msg>fix email in use error<commit_after>moment = require 'moment'

describe 'Api.referrer/Api.referrral', ->
  user = null
  referredUser = null
  refrFixture = null
  reflFixture = null
  referrer = null
  referral = null

  program =
    name: 'Sample Program'
    triggers: [0]
    actions: [
      {
        type:       'credit'
        amount:     1
        currency:   'points'
      }
    ]

  before ->
    user = yield api.account.create
      firstName:       'referrer' + firstName
      lastName:        'referrer' + lastName
      email:           'referrer' + email
      password:        <PASSWORD>
      passwordConfirm: <PASSWORD>

    referredUser = yield api.account.create
      firstName:       'referred' + firstName
      lastName:        'referred' + lastName
      email:           'referred' + email
      password:        <PASSWORD>
      passwordConfirm: <PASSWORD>Pass1

    refrFixture =
      userId: user.id
      orderId: 'orderId'
      program: program

    referrer = yield api.referrer.create refrFixture

    reflFixture =
      referrerId: referrer.id
      referrerUserId: user.id
      userId: referredUser.id
      orderId: 'referredOrderId'

    referral = yield api.referral.create reflFixture

  describe '.list referrer', ->
    it 'should list referrers', ->
      {count, models} = yield api.referrer.list()
{'fraction_non_alphanumeric': 0.0909777274443186, 'fraction_numerical': 0.001887504718761797, 'mean_word_length': 2.049482163406214, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6629626', 'n_tokens_mistral': 808, 'n_tokens_neox': 813, 'n_words': 196}