<commit_before>var store = require('humble-localstorage')

var clone = require('lodash.clone')
var nock = require('nock')
var test = require('tape')

var Account = require('../../index')

var baseURL = 'http://localhost:3000'
var signInResponse = clone(require('../fixtures/signin.json'))

var options = {
  username: '<EMAIL>',
  password: '<PASSWORD>'
}

test('sign in', function (t) {
  store.clear()
  t.plan(9)

  var account = new Account({
    url: baseURL,
    id: 'abc4567'
  })

  nock(baseURL)
    .put('/session')
    .reply(201, signInResponse)

    .delete('/session')
    .reply(204)

  account.signIn(options)

  .then(function () {
    t.pass('signes in')

    var storeAccount = store.getObject('account')

    t.deepEqual(storeAccount, {
      id: 'abc4567',
      username: '<EMAIL>',
      session: {
        id: 'sessionid123'
      }
    }, 'stores account with id with session')
    t.deepEqual(account.get(), {
      id: 'abc4567',
      username: '<EMAIL>',
      session: {
        id: 'sessionid123'
      }
    }, '.get() returns account with session')

    return account.signOut()
  })

  .then(function () {
    t.pass('signes out')

    var storeAccount = store.getObject('account')

    t.is(storeAccount, null, 'removes acocunt from store')

    t.ok(/^[a-z0-9]{7}$/.test(account.id), 'generates new account.id')
    t.isNot(account.id, 'abc4567', 'new id is not same as old id')

    storeAccount = store.getObject('account')
    t.ok(/^[a-z0-9]{7}$/.test(storeAccount.id), 'stores new id')

    t.deepEqual(account.get(), {id: storeAccount.id}, '.get() returns new account id')
  })

  .catch(t.error)
})
<commit_msg>test: prepared failing test for #50<commit_after>var store = require('humble-localstorage')

var clone = require('lodash.clone')
var nock = require('nock')
var test = require('tape')

var Account = require('../../index')

var baseURL = 'http://localhost:3000'
var signInResponse = clone(require('../fixtures/signin.json'))

var options = {
  username: '<EMAIL>',
  password: '<PASSWORD>'
}

test('sign in', function (t) {
  store.clear()
  t.plan(10)

  var account = new Account({
    url: baseURL,
    id: 'abc4567'
  })

  nock(baseURL)
    .put('/session')
    .reply(201, signInResponse)

    .delete('/session')
    .reply(204)

  account.signIn(options)

  .then(function (signInResult) {
    t.pass('signes in')
    t.is(signInResult.username, '<EMAIL>')

    var storeAccount = store.getObject('account')

    t.deepEqual(storeAccount, {
      id: 'abc4567',
      username: '<EMAIL>',
      session: {
        id: 'sessionid123'
      }
    }, 'stores account with id with session')
    t.deepEqual(account.get(), {
      id: 'abc4567',
      username: '<EMAIL>',
      session: {
        id: 'sessionid123'
      }
    }, '.get() returns account with session')

    return account.signOut()
  })

  .then(function (signOutResult) {
    t.pass('signes out')

    // https://github.com/hoodiehq/hoodie-client-account/issues/50
    // t.is(signOutResult.username, '<EMAIL>')

    var storeAccount = store.getObject('account')

    t.is(storeAccount, null, 'removes acocunt from store')

    t.ok(/^[a-z0-9]{7}$/.test(account.id), 'generates new account.id')
    t.isNot(account.id, 'abc4<PASSWORD>', 'new id is not same as old id')

    storeAccount = store.getObject('account')
    t.ok(/^[a-z0-9]{7}$/.test(storeAccount.id), 'stores new id')

    t.deepEqual(account.get(), {id: storeAccount.id}, '.get() returns new account id')
  })

  .catch(t.error)
})

{'fraction_non_alphanumeric': 0.1794944618006248, 'fraction_numerical': 0.02272081794944618, 'mean_word_length': 3.0905923344947737, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 1, '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': '950931', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1215, 'n_words': 260}