<commit_before>import expect from 'expect';

import { validator } from '../validation';

describe('Validation functions:', () => {
  describe('validator', () => {
    it('should not generate error messages for pages if date not provided', () => {
      let metadata = {
        title: 'Test Title',
        path: '2016-01-11-awesome-path-test.md'
      };
      const errorMessages = validator(
        metadata,
        {
          'path': 'required|date',
          'title': 'required'
        },
        {
          'path.required': 'The filename is required.',
          'title.required': 'The title is required.'
        }
      );
      expect(errorMessages).toEqual([]);
    });
    it('should generate error messages if not validated', () => {
      let metadata = {};
      const errorMessages = validator(
        metadata,
        {
          'path': 'required',
          'title': 'required'
        },
        {
          'path.required': 'The filename is required.',
          'title.required': 'The title is required.'
        }
      );
      expect(errorMessages).toEqual([
        'The filename is required.',
        'The title is required.'
      ]);
    });
    it('should generate error messages if filename is not valid', () => {
      let metadata = {
        path: '2016-01-11.md'
      };
      const errorMessages = validator(
        metadata,<commit_msg>improve test descriptions<commit_after>import expect from 'expect';

import { validator } from '../validation';

describe('Validation functions:', () => {
  describe('validator', () => {
    it('should not generate error messages if all fields are valid', () => {
      let metadata = {
        title: 'Test Title',
        path: '2016-01-11-awesome-path-test.md'
      };
      const errorMessages = validator(
        metadata,
        {
          'path': 'required|date',
          'title': 'required'
        },
        {
          'path.required': 'The filename is required.',
          'title.required': 'The title is required.'
        }
      );
      expect(errorMessages).toEqual([]);
    });
    it('should generate error messages if not validated', () => {
      let metadata = {};
      const errorMessages = validator(
        metadata,
        {
          'path': 'required',
          'title': 'required'
        },
        {
          'path.required': 'The filename is required.',
          'title.required': 'The title is required.'
        }
      );
      expect(errorMessages).toEqual([
        'The filename is required.',
        'The title is required.'
      ]);
    });
    it("should generate an error message if a post's filename does not include date", () => {
      let metadata = {
        path: 'test.md'
      };
      const errorMessages = validator(
        metadata,
{'fraction_non_alphanumeric': 0.14039497307001794, 'fraction_numerical': 0.008617594254937163, 'mean_word_length': 1.920335429769392, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '2273263', 'n_tokens_mistral': 745, 'n_tokens_neox': 728, 'n_words': 206}