<commit_before>import { inspect } from "util"

import test from "ava"
import { v4 } from "uuid"

import databaseHook from "./../../../../helpers/database"

import Email from "./../../../../../src/app/models/email"
import User from "./../../../../../src/app/models/user"

databaseHook(test)

test.serial("createWithPassword given sufficient data", async t => {
  const initialUserCount = await parseInt(User.count(), 10)
  const initialEmailCount = await parseInt(Email.count(), 10)

  const user = await User.createWithPassword({
    email: `<EMAIL>`,
    password: "<PASSWORD>"
  })

  t.not(user.id, undefined)

  t.is(await parseInt(User.count(), 10), initialUserCount + 1)
  t.is(await parseInt(Email.count(), 10), initialEmailCount + 1)
})

test.serial("automatically hashes password before save", async t => {
  const password = "<PASSWORD>"
  const user = User.forge()

  t.is(user.password, undefined)
  t.is(user.passwordHash, undefined)<commit_msg>factor integer parsing into method<commit_after>import test from "ava"

import { partialRight } from "ramda"
import { v4 } from "uuid"

import databaseHook from "./../../../../helpers/database"

import Email from "./../../../../../src/app/models/email"
import User from "./../../../../../src/app/models/user"

databaseHook(test)

const int = partialRight(parseInt, [10])

test.serial("createWithPassword given sufficient data", async t => {
  const initialUserCount = await int(User.count())
  const initialEmailCount = await int(Email.count())

  const user = await User.createWithPassword({
    email: `<EMAIL>`,
    password: "<PASSWORD>"
  })

  t.not(user.id, undefined)

  t.is(await int(User.count()), initialUserCount + 1)
  t.is(await int(Email.count()), initialEmailCount + 1)
})

test.serial("automatically hashes password before save", async t => {
  const password = "<PASSWORD>"
  const user = User.forge()

  t.is(user.password, undefined)
  t.is(user.passwordHash, undefined)
{'fraction_non_alphanumeric': 0.17650076962544894, 'fraction_numerical': 0.008209338122113904, 'mean_word_length': 3.676258992805755, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '6262609', 'n_tokens_mistral': 608, 'n_tokens_neox': 593, 'n_words': 159}