<commit_before>/*
 * env.js: Tests for `jitsu env *` command(s).
 *
 * (C) 2010, Nodejitsu Inc.
 *
 */
 
var assert = require('assert'),
    fs = require('fs'),
    path = require('path'),
    flatiron = require('flatiron'),
    nock = require('nock'),
    vows = require('vows'),
    jitsu = require('../../lib/jitsu'),
    macros = require('../helpers/macros');

var shouldNodejitsuOk = macros.shouldNodejitsuOk;

var elvis = {
  username: 'elvis',
  email: '<EMAIL>',
  password: '<PASSWORD>'
};

var jimmy = { 
  username: "jimmy",
  email: "<EMAIL>",
  password: "<PASSWORD>"
};

vows.describe('jitsu/commands/users').addBatch({
  'users create elvis': shouldNodejitsuOk(function setup() {
    jitsu.prompt.override = flatiron.common.clone(elvis);
    jitsu.prompt.override['confirm password'] = <PASSWORD>;
    
    nock('http://api.mockjitsu.com')
      .post('/users/elvis', elvis)
      .reply(200, '', { 'x-powered-by': 'Nodejitsu' })
  })
}).addBatch({
  'users create elvis': shouldNodejitsuOk(
    'should respond with a 400 error',
    function assertion (ign, err) {
      err = ign;
      assert.equal(err.statusCode, '400');
    },
    function setup() {
      jitsu.prompt.override = flatiron.common.clone(elvis);
      jitsu.prompt.override['confirm password'] = <PASSWORD>;

      nock('http://api.mockjitsu.com')
        .post('/users/elvis', elvis)
        .reply(400, '', { 'x-powered-by': 'Nodejitsu' })
    })
}).addBatch({
  'users create elvis': shouldNodejitsuOk(
    'should respond with a 500 error',
    function assertion (ign, err) {
      err = ign;
      assert.equal(err.statusCode, '500');
    },
    function setup() {
      jitsu.prompt.override = flatiron.common.clone(elvis);
      jitsu.prompt.override['confirm password'] = <PASSWORD>;

      nock('http://api.mockjitsu.com')
        .post('/users/elvis', elvis)
        .reply(500, '', { 'x-powered-by': 'Nodejitsu' })
    })
}).addBatch({
  'users create jimmy': shouldNodejitsuOk(function setup() {
    jitsu.prompt.override = flatiron.common.clone(jimmy);
    jitsu.prompt.override['confirm password'] = <PASSWORD>;
    
    nock('http://api.mockjitsu.com')
      .post('/users/jimmy', jimmy)
      .reply(200, '', { 'x-powered-by': 'Nodejitsu' })
  })
}).addBatch({
  'users available jimmy': shouldNodejitsuOk(function setup() {
    nock('http://api.mockjitsu.com')
      .get('/users/jimmy/available')
      .reply(200, { available: true }, { 'x-powered-by': 'Nodejitsu' })
  })
}).addBatch({
  'users confirm jimmy': shouldNodejitsuOk(function setup() {
    jitsu.prompt.override['invite code'] = 'f4387f4';
    jitsu.prompt.override['set password'] = '<PASSWORD>';
    jitsu.prompt.override['confirm password'] = '<PASSWORD>';
    
    var testConf = path.join(__dirname, '..', 'fixtures', 'test-jitsuconf'),
        conf = path.join(__dirname, '..', 'fixtures', 'dot-jitsuconf');
        
    fs.writeFileSync(
      testConf, 
      fs.readFileSync(conf, 'utf8'),
      'utf8'
    );
    
    jitsu.config.stores.file.file = testConf;
    jitsu.config.stores.file.loadSync();
    
    nock('http://api.mockjitsu.com')
      .post('/users/jimmy/confirm', { username: 'jimmy', inviteCode: 'f4387f4'})
      .reply(200, {
        username: 'jimmy',
        inviteCode: 'f4387f4'
      }, { 'x-powered-by': 'Nodejitsu' })
  })
})/*.addBatch({
  'users confirm jimmy': runJitsuCommand(
    mockPrompt({ 'Invite code': 'f4387f4' }),
    mockRequest.mock(helper.mockOptions, helper.mockDefaults)
      .post('/users/jimmy/confirm')
      .respond({
        body: {
          error: 'username jimmy is taken'
        }
      })
    )
}).addBatch({
  'users forgot jimmy': runJitsuCommand(
    mockRequest.mock(helper.mockOptions, helper.mockDefaults)
      .post('/users/jimmy/forgot'))
})*/.export(module);
<commit_msg>[fix test] Minor test fix for `users confirm`<commit_after>/*
 * env.js: Tests for `jitsu env *` command(s).
 *
 * (C) 2010, Nodejitsu Inc.
 *
 */
 
var assert = require('assert'),
    fs = require('fs'),
    path = require('path'),
    flatiron = require('flatiron'),
    nock = require('nock'),
    vows = require('vows'),
    jitsu = require('../../lib/jitsu'),
    macros = require('../helpers/macros');

var shouldNodejitsuOk = macros.shouldNodejitsuOk;

var elvis = {
  username: 'elvis',
  email: '<EMAIL>',
  password: '<PASSWORD>'
};

var jimmy = { 
  username: "jimmy",
  email: "<EMAIL>",
  password: "<PASSWORD>"
};

vows.describe('jitsu/commands/users').addBatch({
  'users create elvis': shouldNodejitsuOk(function setup() {
    jitsu.prompt.override = flatiron.common.clone(elvis);
    jitsu.prompt.override['confirm password'] = <PASSWORD>;
    
    nock('http://api.mockjitsu.com')
      .post('/users/elvis', elvis)
      .reply(200, '', { 'x-powered-by': 'Nodejitsu' })
  })
}).addBatch({
  'users create elvis': shouldNodejitsuOk(
    'should respond with a 400 error',
    function assertion (ign, err) {
      err = ign;
      assert.equal(err.statusCode, '400');
    },
    function setup() {
      jitsu.prompt.override = flatiron.common.clone(elvis);
      jitsu.prompt.override['confirm password'] = <PASSWORD>;

      nock('http://api.mockjitsu.com')
        .post('/users/elvis', elvis)
        .reply(400, '', { 'x-powered-by': 'Nodejitsu' })
    })
}).addBatch({
  'users create elvis': shouldNodejitsuOk(
    'should respond with a 500 error',
    function assertion (ign, err) {
      err = ign;
      assert.equal(err.statusCode, '500');
    },
    function setup() {
      jitsu.prompt.override = flatiron.common.clone(elvis);
      jitsu.prompt.override['confirm password'] = <PASSWORD>;

      nock('http://api.mockjitsu.com')
        .post('/users/elvis', elvis)
        .reply(500, '', { 'x-powered-by': 'Nodejitsu' })
    })
}).addBatch({
  'users create jimmy': shouldNodejitsuOk(function setup() {
    jitsu.prompt.override = flatiron.common.clone(jimmy);
    jitsu.prompt.override['confirm password'] = <PASSWORD>;
    
    nock('http://api.mockjitsu.com')
      .post('/users/jimmy', jimmy)
      .reply(200, '', { 'x-powered-by': 'Nodejitsu' })
  })
}).addBatch({
  'users available jimmy': shouldNodejitsuOk(function setup() {
    nock('http://api.mockjitsu.com')
      .get('/users/jimmy/available')
      .reply(200, { available: true }, { 'x-powered-by': 'Nodejitsu' })
  })
}).addBatch({
  'users confirm jimmy': shouldNodejitsuOk(function setup() {
    jitsu.prompt.override['invite code'] = 'f4387f4';
    jitsu.prompt.override['set password'] = '<PASSWORD>';
    jitsu.prompt.override['confirm password'] = '<PASSWORD>';
    
    var testConf = path.join(__dirname, '..', 'fixtures', 'test-jitsuconf'),
        conf = path.join(__dirname, '..', 'fixtures', 'dot-jitsuconf');
        
    fs.writeFileSync(
      testConf, 
      fs.readFileSync(conf, 'utf8'),
      'utf8'
    );
    
    jitsu.config.stores.file.file = testConf;
    jitsu.config.stores.file.loadSync();
    
    nock('http://api.mockjitsu.com')
      .post('/users/jimmy/confirm', { username: 'jimmy', inviteCode: 'f4387f4'})
        .reply(200, {
          username: 'jimmy',
          inviteCode: 'f4387f4'
        }, { 'x-powered-by': 'Nodejitsu' })
      .post('/users/jimmy/forgot', { 'new-password': '<PASSWORD>' })
        .reply(200, { 'set-password': '<PASSWORD>' }, { 'x-powered-by': 'Nodejitsu' })
  })
})/*.addBatch({
  'users confirm jimmy': runJitsuCommand(
    mockPrompt({ 'Invite code': 'f4387f4' }),
    mockRequest.mock(helper.mockOptions, helper.mockDefaults)
      .post('/users/jimmy/confirm')
      .respond({
        body: {
          error: 'username jimmy is taken'
        }
      })
    )
}).addBatch({
  'users forgot jimmy': runJitsuCommand(
    mockRequest.mock(helper.mockOptions, helper.mockDefaults)
      .post('/users/jimmy/forgot'))
})*/.export(module);

{'fraction_non_alphanumeric': 0.18791517629024015, 'fraction_numerical': 0.014690853346959631, 'mean_word_length': 3.033487892838743, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '5753002', 'n_tokens_mistral': 2890, 'n_tokens_neox': 2701, 'n_words': 477}