<commit_before>var assert = require('assert');
var range = require('lodash/range');

var journalize = require('../src');

describe('apnumber', () => {
  it('should correctly convert numbers', () => {
    var test_list = range(-1, 11).map((n) => n.toString());

    var result_list = ['-1', '0', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', '10'];

    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.apnumber(n), result_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.apnumber(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.apnumber(null), '');
  });

  it('should return original input when input is not a number', () => {
    assert.deepEqual(journalize.apnumber('corgi'), 'corgi');
  });

  it('should return original input when input is not an integer', () => {
    assert.deepEqual(journalize.apnumber('1.234'), '1.234');
  });
});

describe('ordinal', () => {
  it('should correctly convert ordinals', () => {
    var test_list = ['1', '2', '3', '4', '11', '12', '13', '101', '102', '103', '111'];
    var result_list = ['1st', '2nd', '3rd', '4th', '11th', '12th', '13th', '101st', '102nd', '103rd', '111th'];

    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.ordinal(n), result_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.ordinal(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.ordinal(null), '');
  });

  it('should return original input when input is not a number', () => {
    assert.deepEqual(journalize.ordinal('corgi'), 'corgi');
  });

  it('should return original input when input is not an integer', () => {
    assert.deepEqual(journalize.ordinal('1.234'), '1.234');
  });
});

describe('intword', () => {
  it('should correctly convert integers to words', () => {
    var test_list = ['100', '1000000', '1200000', '1290000', '12000000', '1000000000', '2000000000', '6000000000000', '603000000000000', '1300000000000000', '3500000000000000000000', '8100000000000000000000000000000000'];
    var result_list = ['100', '1 million', '1.2 million', '1.3 million', '12 million', '1 billion', '2 billion', '6 trillion', '603 trillion', '1.3 quadrillion', '3.5 sextillion', '8.1 decillion'];

    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.intword(n), result_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.intword(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.intword(null), '');
  });

  it('should return original input when input is not a number', () => {
    assert.deepEqual(journalize.intword('corgi'), 'corgi');
  });

  it('should return original input when input is not an integer', () => {
    assert.deepEqual(journalize.intword('1.234'), '1.234');
  });
});

describe('intcomma', () => {
  it('should successfully add commas to numbers', () => {
    var test_list = [100, 1000, 10123, 10311, 1000000, 1234567.25, '100', '1000', '10123', '10311', '1000000', '1234567.1234567'];
    var result_list = ['100', '1,000', '10,123', '10,311', '1,000,000', '1,234,567.25', '100', '1,000', '10,123', '10,311', '1,000,000', '1,234,567.1234567'];

    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.intcomma(n), result_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.intcomma(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.intcomma(null), '');
  });

  it('should return original input when input is not a number', () => {
    assert.deepEqual(journalize.intcomma('corgi'), 'corgi');
  });
});<commit_msg>Hook up tests for apstate<commit_after>var assert = require('assert');
var range = require('lodash/range');

var journalize = require('../src');

describe('apnumber', () => {
  it('should correctly convert numbers', () => {
    var test_list = range(-1, 11).map((n) => n.toString());

    var result_list = ['-1', '0', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', '10'];

    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.apnumber(n), result_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.apnumber(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.apnumber(null), '');
  });

  it('should return original input when input is not a number', () => {
    assert.deepEqual(journalize.apnumber('corgi'), 'corgi');
  });

  it('should return original input when input is not an integer', () => {
    assert.deepEqual(journalize.apnumber('1.234'), '1.234');
  });
});

describe('ordinal', () => {
  it('should correctly convert ordinals', () => {
    var test_list = ['1', '2', '3', '4', '11', '12', '13', '101', '102', '103', '111'];
    var result_list = ['1st', '2nd', '3rd', '4th', '11th', '12th', '13th', '101st', '102nd', '103rd', '111th'];

    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.ordinal(n), result_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.ordinal(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.ordinal(null), '');
  });

  it('should return original input when input is not a number', () => {
    assert.deepEqual(journalize.ordinal('corgi'), 'corgi');
  });

  it('should return original input when input is not an integer', () => {
    assert.deepEqual(journalize.ordinal('1.234'), '1.234');
  });
});

describe('intword', () => {
  it('should correctly convert integers to words', () => {
    var test_list = ['100', '1000000', '1200000', '1290000', '12000000', '1000000000', '2000000000', '6000000000000', '603000000000000', '1300000000000000', '3500000000000000000000', '8100000000000000000000000000000000'];
    var result_list = ['100', '1 million', '1.2 million', '1.3 million', '12 million', '1 billion', '2 billion', '6 trillion', '603 trillion', '1.3 quadrillion', '3.5 sextillion', '8.1 decillion'];

    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.intword(n), result_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.intword(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.intword(null), '');
  });

  it('should return original input when input is not a number', () => {
    assert.deepEqual(journalize.intword('corgi'), 'corgi');
  });

  it('should return original input when input is not an integer', () => {
    assert.deepEqual(journalize.intword('1.234'), '1.234');
  });
});

describe('intcomma', () => {
  it('should successfully add commas to numbers', () => {
    var test_list = [100, 1000, 10123, 10311, 1000000, 1234567.25, '100', '1000', '10123', '10311', '1000000', '1234567.1234567'];
    var result_list = ['100', '1,000', '10,123', '10,311', '1,000,000', '1,234,567.25', '100', '1,000', '10,123', '10,311', '1,000,000', '1,234,567.1234567'];

    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.intcomma(n), result_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.intcomma(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.intcomma(null), '');
  });

  it('should return original input when input is not a number', () => {
    assert.deepEqual(journalize.intcomma('corgi'), 'corgi');
  });
});

describe('apstate', () => {
  var test_list = ['Arizona', 'Texas', 'District of Columbia', 'Wyoming', 'Ontario'];
  var result_list = ['Ariz.', 'Texas', 'D.C.', 'Wyo.', 'Ontario'];

  it('should convert state names into AP abbreviations', () => {
    test_list.forEach((n, idx) => {
      assert.deepEqual(journalize.apstate(n), result_list[idx]);
    });
  });

  it('should convert AP abbreviations into state names', () => {
    result_list.forEach((n, idx) => {
      assert.deepEqual(journalize.apstate(n, true), test_list[idx]);
    });
  });

  it('should return empty string when input is `undefined`', () => {
    assert.deepEqual(journalize.apstate(undefined), '');
  });

  it('should return empty string when input is `null`', () => {
    assert.deepEqual(journalize.apstate(null), '');
  });

  it('should return original input when input is not a string', () => {
    assert.deepEqual(journalize.apstate(42), 42);
  });
});
{'fraction_non_alphanumeric': 0.2123962368566685, 'fraction_numerical': 0.08699501936912009, 'mean_word_length': 4.3059307105108635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 67, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 14, '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': '4686739', 'n_tokens_mistral': 3549, 'n_tokens_neox': 2954, 'n_words': 708}