<commit_before>/* eslint-env mocha */

'use strict';

const assert = require('assert');
const fakeDate = require('.');

describe('fakeDate', () => {
  describe('factory', () => {
    it('is a function', () => {
      assert.strictEqual(typeof fakeDate, 'function');
    });
    it('requires option object', () => {
      assert.throws(() => fakeDate(), /match/);
    });
    it('allows empty option object', () => {
      fakeDate({});
    });
    it('referenceTime must be a number', () => {
      assert.throws(() => fakeDate({ referenceTime: '0' }), /number/);
    });
    it('referenceTime must be an integer', () => {
      assert.throws(() => fakeDate({ referenceTime: 0.1 }), /integer/);
    });
    it('timezoneOffset must be a number', () => {
      assert.throws(() => fakeDate({ timezoneOffset: '0' }), /number/);
    });
    it('timezoneOffset must be an integer', () => {
      assert.throws(() => fakeDate({ timezoneOffset: 0.1 }), /integer/);
    });
  });
  describe('constructor', () => {
    it('is a function', () => {
      const FakeDate = fakeDate({});
      assert.strictEqual(typeof FakeDate, 'function');
    });
    it('constructs with no args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(); // eslint-disable-line no-new
    });
    it('constructs with one numeric arg', () => {
      const FakeDate = fakeDate({});
      new FakeDate(1); // eslint-disable-line no-new
    });
    it('constructs with one string arg', () => {
      const FakeDate = fakeDate({});
      new FakeDate('2000-01-01'); // eslint-disable-line no-new
    });
    it('constructs with two args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0); // eslint-disable-line no-new
    });
    it('constructs with three args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1); // eslint-disable-line no-new
    });
    it('constructs with four args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1, 0); // eslint-disable-line no-new
    });
    it('constructs with five args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1, 0, 0); // eslint-disable-line no-new
    });
    it('constructs with six args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1, 0, 0, 0); // eslint-disable-line no-new
    });
    it('constructs with seven args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1, 0, 0, 0, 0); // eslint-disable-line no-new
    });
  });
  describe('statics', () => {
    describe('now', () => {
      it('returns a number', () => {
        const FakeDate = fakeDate({});
        assert.strictEqual(typeof FakeDate.now(), 'number');
      });
      it('returns an integer', () => {
        const FakeDate = fakeDate({});
        assert.ok(Number.isInteger(FakeDate.now()), 'not integer');
      });
      it('returns same time as provided in factory', () => {
        const FakeDate = fakeDate({ referenceTime: 1000 });
        assert.strictEqual(FakeDate.now(), 1000);
      });
      it('defaults to zero if not provided in factory', () => {
        const FakeDate = fakeDate({});
        assert.strictEqual(FakeDate.now(), 0);
      });
    });
    describe('UTC', () => {
      it('returns a number', () => {
        const FakeDate = fakeDate({});
        assert.strictEqual(typeof FakeDate.UTC(2011, 0), 'number');
      });
      it('returns an integer', () => {
        const FakeDate = fakeDate({});
        assert.ok(Number.isInteger(FakeDate.UTC(2011, 0)), 'not integer');
      });
      it('returns NaN on string input', () => {
        const FakeDate = fakeDate({});
        assert.ok(isNaN(FakeDate.UTC('f')));
      });
      it('correct epoch', () => {
        const FakeDate = fakeDate({});
        const expected = Date.UTC(1970, 0);
        const actual = FakeDate.UTC(1970, 0);
        assert.strictEqual(actual, expected);
      });
      it('correct modern date', () => {
        const FakeDate = fakeDate({});
        const expected = Date.UTC(2016, 6, 5);
        const actual = FakeDate.UTC(2016, 6, 5);
        assert.strictEqual(actual, expected);
      });
      it('requires multiple args', () => {
        const FakeDate = fakeDate({});
        const time = FakeDate.UTC(2016);
        assert.ok(isNaN(time));
      });
    });
    describe('parse', () => {
      it('returns a number', () => {
        const FakeDate = fakeDate({});
        assert.strictEqual(typeof FakeDate.parse('2001-01-01'), 'number');
      });
      it('returns an integer', () => {
        const FakeDate = fakeDate({});
        assert.ok(Number.isInteger(FakeDate.parse('2001-01-01')), 'not integer');
      });
      it('parses ISO', () => {
        const FakeDate = fakeDate({});
        assert.ok(FakeDate.parse('2001-01-01') > 0);
      });
      it('parses 2822', () => {
        const FakeDate = fakeDate({});
        assert.ok(FakeDate.parse('Jan 2, 1970') > 0);
      });
      it('returns NaN for un-parseable string', () => {
        const FakeDate = fakeDate({});
        assert.ok(isNaN(FakeDate.parse('1234567---')));
      });
      it('treats unqualified ISO as UTC', () => {
        const FakeDate = fakeDate({});
        const actual = FakeDate.parse('2001-01-01');
        const expected = Date.UTC(2001, 0, 1);<commit_msg>fixes original tests<commit_after>/* eslint-env mocha */

'use strict';

const assert = require('assert');
const fakeDate = require('.');

describe('fakeDate', () => {
  describe('factory', () => {
    it('is a function', () => {
      assert.strictEqual(typeof fakeDate, 'function');
    });
    it('requires option object', () => {
      assert.throws(() => fakeDate(), /TypeError/);
    });
    it('allows empty option object', () => {
      fakeDate({});
    });
    it('referenceTime must be a number', () => {
      assert.throws(() => fakeDate({ referenceTime: '0' }), /number/);
    });
    it('referenceTime must be an integer', () => {
      assert.throws(() => fakeDate({ referenceTime: 0.1 }), /integer/);
    });
    it('timezoneOffset must be a number', () => {
      assert.throws(() => fakeDate({ timezoneOffset: '0' }), /number/);
    });
    it('timezoneOffset must be an integer', () => {
      assert.throws(() => fakeDate({ timezoneOffset: 0.1 }), /integer/);
    });
  });
  describe('constructor', () => {
    it('is a function', () => {
      const FakeDate = fakeDate({});
      assert.strictEqual(typeof FakeDate, 'function');
    });
    it('constructs with no args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(); // eslint-disable-line no-new
    });
    it('constructs with one numeric arg', () => {
      const FakeDate = fakeDate({});
      new FakeDate(1); // eslint-disable-line no-new
    });
    it('constructs with one string arg', () => {
      const FakeDate = fakeDate({});
      new FakeDate('2000-01-01'); // eslint-disable-line no-new
    });
    it('constructs with two args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0); // eslint-disable-line no-new
    });
    it('constructs with three args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1); // eslint-disable-line no-new
    });
    it('constructs with four args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1, 0); // eslint-disable-line no-new
    });
    it('constructs with five args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1, 0, 0); // eslint-disable-line no-new
    });
    it('constructs with six args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1, 0, 0, 0); // eslint-disable-line no-new
    });
    it('constructs with seven args', () => {
      const FakeDate = fakeDate({});
      new FakeDate(2001, 0, 1, 0, 0, 0, 0); // eslint-disable-line no-new
    });
  });
  describe('statics', () => {
    describe('now', () => {
      it('returns a number', () => {
        const FakeDate = fakeDate({});
        assert.strictEqual(typeof FakeDate.now(), 'number');
      });
      it('returns an integer', () => {
        const FakeDate = fakeDate({});
        assert.ok(Number.isInteger(FakeDate.now()), 'not integer');
      });
      it('returns same time as provided in factory', () => {
        const FakeDate = fakeDate({ referenceTime: 1000 });
        assert.strictEqual(FakeDate.now(), 1000);
      });
      it('defaults to zero if not provided in factory', () => {
        const FakeDate = fakeDate({});
        assert.strictEqual(FakeDate.now(), 0);
      });
    });
    describe('UTC', () => {
      it('returns a number', () => {
        const FakeDate = fakeDate({});
        assert.strictEqual(typeof FakeDate.UTC(2011, 0), 'number');
      });
      it('returns an integer', () => {
        const FakeDate = fakeDate({});
        assert.ok(Number.isInteger(FakeDate.UTC(2011, 0)), 'not integer');
      });
      it('returns NaN on string input', () => {
        const FakeDate = fakeDate({});
        assert.ok(isNaN(FakeDate.UTC('f')));
      });
      it('correct epoch', () => {
        const FakeDate = fakeDate({});
        const expected = Date.UTC(1970, 0);
        const actual = FakeDate.UTC(1970, 0);
        assert.strictEqual(actual, expected);
      });
      it('correct modern date', () => {
        const FakeDate = fakeDate({});
        const expected = Date.UTC(2016, 6, 5);
        const actual = FakeDate.UTC(2016, 6, 5);
        assert.strictEqual(actual, expected);
      });
      it('requires multiple args', () => {
        const FakeDate = fakeDate({});
        const time = FakeDate.UTC();
        assert.ok(isNaN(time));
      });
    });
    describe('parse', () => {
      it('returns a number', () => {
        const FakeDate = fakeDate({});
        assert.strictEqual(typeof FakeDate.parse('2001-01-01'), 'number');
      });
      it('returns an integer', () => {
        const FakeDate = fakeDate({});
        assert.ok(Number.isInteger(FakeDate.parse('2001-01-01')), 'not integer');
      });
      it('parses ISO', () => {
        const FakeDate = fakeDate({});
        assert.ok(FakeDate.parse('2001-01-01') > 0);
      });
      it('parses 2822', () => {
        const FakeDate = fakeDate({});
        assert.ok(FakeDate.parse('Jan 2, 1970') > 0);
      });
      it('returns NaN for un-parseable string', () => {
        const FakeDate = fakeDate({});
        assert.ok(isNaN(FakeDate.parse('1234567---')));
      });
      it('treats unqualified ISO as UTC', () => {
        const FakeDate = fakeDate({});
        const actual = FakeDate.parse('2001-01-01');
        const expected = Date.UTC(2001, 0, 1);
{'fraction_non_alphanumeric': 0.19773217130540718, 'fraction_numerical': 0.02980039359010402, 'mean_word_length': 2.475089547378704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 97, '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': '2301642', 'n_tokens_mistral': 3552, 'n_tokens_neox': 3298, 'n_words': 765}