<commit_before>import test from 'tape'
import ChunkifyOptions from './options'


test('should throw when receiving non-object literal options', t => {
  let WRONG_TYPES = [
    false,
    true,
    null,
    undefined,
    [],
    function() {}
  ];
  for (let thing of WRONG_TYPES) {
    t.throws(() => {
      ChunkifyOptions.of(thing)
    }, new RegExp(`Expected options object, got ${typeof thing}`))
  }
  t.end()
});

test('should have defaults', t => {
  let options = ChunkifyOptions.of({});
  t.equals(typeof options.delay, 'number');
  t.equals(typeof options.chunk, 'number');
  t.end()
});

test('should override all defaults', t => {
  let chunk = 50;
  let delay = 100;

  let options = ChunkifyOptions.of({chunk, delay});

  t.equals(options.chunk, chunk);
  t.equals(options.delay, delay);
  t.end()
});

test('should override some defaults', t => {
  let chunk = 50;
  let delay = 100;

  let options = ChunkifyOptions.of({chunk});

  t.equals(options.chunk, chunk);
  t.notEquals(options.delay, delay);

  options = ChunkifyOptions.of({delay});

  t.equals(options.delay, delay);
  t.notEquals(options.chunk, chunk);

  t.end()
});

test('should throw when an option override has the wrong type', t => {
  let chunk = function() {};
  let delay = [];

  t.throws(() => {
    ChunkifyOptions.of({chunk})
  }, /Expected 'chunk' to be 'number', got 'function'/);
  t.throws(() => {
    ChunkifyOptions.of({delay})
  }, /Expected 'delay' to be 'number', got 'object'/);
  t.end()
});

test('should be immutable', t => {
  let chunk = 50;
  let delay = 100;

  let options = ChunkifyOptions.of({chunk, delay});

  t.throws(() => {
    options.delay = 0
  }, /delay is immutable/);
  t.throws(() => {<commit_msg>test wrong values<commit_after>import test from 'tape'
import ChunkifyOptions from './options'


test('should throw when receiving non-object literal options', t => {
  let WRONG_TYPES = [
    false,
    true,
    null,
    undefined,
    [],
    function() {}
  ];
  for (let thing of WRONG_TYPES) {
    t.throws(() => {
      ChunkifyOptions.of(thing)
    }, new RegExp(`Expected options object, got ${typeof thing}`))
  }
  t.end()
});

test('should have defaults', t => {
  let options = ChunkifyOptions.of({});
  t.equals(typeof options.delay, 'number');
  t.equals(typeof options.chunk, 'number');
  t.end()
});

test('should override all defaults', t => {
  let chunk = 50;
  let delay = 100;

  let options = ChunkifyOptions.of({chunk, delay});

  t.equals(options.chunk, chunk);
  t.equals(options.delay, delay);
  t.end()
});

test('should override some defaults', t => {
  let chunk = 50;
  let delay = 100;

  let options = ChunkifyOptions.of({chunk});

  t.equals(options.chunk, chunk);
  t.notEquals(options.delay, delay);

  options = ChunkifyOptions.of({delay});

  t.equals(options.delay, delay);
  t.notEquals(options.chunk, chunk);

  t.end()
});

test('should throw when an option override has the wrong type', t => {
  let chunk = function() {};
  let delay = [];

  t.throws(() => {
    ChunkifyOptions.of({chunk})
  }, /'chunk' should be a positive number/);
  t.throws(() => {
    ChunkifyOptions.of({delay})
  }, /'delay' should be a non-negative number/);
  t.end()
});

test('should throw when an option override has the wrong value', t => {
  let chunk = function() {};
  let delay = [];

  t.throws(() => {
    ChunkifyOptions.of({chunk})
  }, /'chunk' should be a positive number/);
  t.throws(() => {
    ChunkifyOptions.of({delay})
  }, /'delay' should be a non-negative number/);
  t.end()
});

test('should be immutable', t => {
  let chunk = 50;
  let delay = 100;

  let options = ChunkifyOptions.of({chunk, delay});

  t.throws(() => {
    options.delay = 0
  }, /delay is immutable/);
  t.throws(() => {
{'fraction_non_alphanumeric': 0.17662682602921648, 'fraction_numerical': 0.00849933598937583, 'mean_word_length': 3.3587962962962963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, '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': '2839264', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1252, 'n_words': 339}