<commit_before>const testFixtureMaker = require('../src/testing/test-fixture-maker');
const errorFormatter = require('../src/testing/validation-error-formatter');

describe('Date/time validation type', () => {
  const testFixture = testFixtureMaker.initFromSyncFunction('build/sync-functions/test-datetime-sync-function.js');

  afterEach(() => {
    testFixture.resetTestEnvironment();
  });

  describe('simple format validation', () => {
    it('accepts a valid date/time with time and time zone components', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17T15:20:09.348-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time with a time component but no time zone', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17T15:20:09.348'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time with neither time nor time zone components', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time without a day', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07T15:20:09.348-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time without month and day', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016T15:20:09.348-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time with only a year', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time without milliseconds', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17T15:20:09-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time without seconds and milliseconds', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17T15:20-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a leap day for a year that is a multiple of four', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '0008-02-29T05:10+05:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a leap day for a year that is a multiple of 400', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '0400-02-29T21:21+01:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a leap day for year 0 (1 BCE)', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '0000-02-29T00:00:00.328Z'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a date/time with midnight specified as hour zero', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-03T00:00:00.000Z'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a date/time with midnight specified as hour 24', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-02T24:00:00+0300'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('rejects a date/time with a time that is one millisecond over the maximum', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-02T24:00:00.001+0300'
      };

      testFixture.verifyDocumentNotCreated(doc, 'datetimeDoc', errorFormatter.datetimeFormatInvalid('formatValidationProp'));
    });

    it('rejects a date/time with a time that is one second over the maximum', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-02T24:00:01.000+0300'
      };

      testFixture.verifyDocumentNotCreated(doc, 'datetimeDoc', errorFormatter.datetimeFormatInvalid('formatValidationProp'));
    });

    it('rejects a date/time with a time that is one minute over the maximum', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-02T24:01:00.000+0300'
      };

      testFixture.verifyDocumentNotCreated(doc, 'datetimeDoc', errorFormatter.datetimeFormatInvalid('formatValidationProp'));
    });

    it('rejects a date/time with an invalid year', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '10000-07-17T15:20:09.348-07:00'
      };

      testFixture.verifyDocumentNotCreated(doc, 'datetimeDoc', errorFormatter.datetimeFormatInvalid('formatValidationProp'));
    });<commit_msg>Issue #282: Add missing colons to time zones in datetime test cases<commit_after>const testFixtureMaker = require('../src/testing/test-fixture-maker');
const errorFormatter = require('../src/testing/validation-error-formatter');

describe('Date/time validation type', () => {
  const testFixture = testFixtureMaker.initFromSyncFunction('build/sync-functions/test-datetime-sync-function.js');

  afterEach(() => {
    testFixture.resetTestEnvironment();
  });

  describe('simple format validation', () => {
    it('accepts a valid date/time with time and time zone components', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17T15:20:09.348-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time with a time component but no time zone', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17T15:20:09.348'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time with neither time nor time zone components', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time without a day', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07T15:20:09.348-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time without month and day', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016T15:20:09.348-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time with only a year', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time without milliseconds', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17T15:20:09-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a valid date/time without seconds and milliseconds', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2016-07-17T15:20-07:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a leap day for a year that is a multiple of four', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '0008-02-29T05:10+05:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a leap day for a year that is a multiple of 400', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '0400-02-29T21:21+01:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a leap day for year 0 (1 BCE)', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '0000-02-29T00:00:00.328Z'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a date/time with midnight specified as hour zero', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-03T00:00:00.000Z'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('accepts a date/time with midnight specified as hour 24', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-02T24:00:00+03:00'
      };

      testFixture.verifyDocumentCreated(doc);
    });

    it('rejects a date/time with a time that is one millisecond over the maximum', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-02T24:00:00.001+03:00'
      };

      testFixture.verifyDocumentNotCreated(doc, 'datetimeDoc', errorFormatter.datetimeFormatInvalid('formatValidationProp'));
    });

    it('rejects a date/time with a time that is one second over the maximum', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-02T24:00:01.000+03:00'
      };

      testFixture.verifyDocumentNotCreated(doc, 'datetimeDoc', errorFormatter.datetimeFormatInvalid('formatValidationProp'));
    });

    it('rejects a date/time with a time that is one minute over the maximum', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '2018-04-02T24:01:00.000+03:00'
      };

      testFixture.verifyDocumentNotCreated(doc, 'datetimeDoc', errorFormatter.datetimeFormatInvalid('formatValidationProp'));
    });

    it('rejects a date/time with an invalid year', () => {
      const doc = {
        _id: 'datetimeDoc',
        formatValidationProp: '10000-07-17T15:20:09.348-07:00'
      };

      testFixture.verifyDocumentNotCreated(doc, 'datetimeDoc', errorFormatter.datetimeFormatInvalid('formatValidationProp'));
    });
{'fraction_non_alphanumeric': 0.13705583756345177, 'fraction_numerical': 0.06040609137055838, 'mean_word_length': 2.7456273764258556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 43, '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': '2604116', 'n_tokens_mistral': 3374, 'n_tokens_neox': 2946, 'n_words': 637}