<commit_before>/* global describe, it */
var chai = require('chai');
var expect = chai.expect;
var data = require('../dist/data');
var path  = require('path');

describe ('data', () => {
  describe('parsing layouts', () => {
    it ('should correctly parse layout files', done => {
      data.prepareLayouts({ layouts: path
        .join(__dirname, 'fixtures/layouts/**/*.html') })
        .then(layoutData => {
          expect(layoutData).to.be.an('Object')
            .and.to.contain.keys('default');
          expect(layoutData.default).to.be.a('string');
          done();
        });
    });
  });
  describe('parsing pages', () => {<commit_msg>Add tests for data parsing<commit_after>/* global describe, it */
var chai = require('chai');
var expect = chai.expect;
var data = require('../dist/data');
var path  = require('path');
var yaml  = require('js-yaml');

describe ('data', () => {
  describe('parsing layouts', () => {
    it ('should correctly parse layout files', done => {
      data.prepareLayouts({ layouts: path
        .join(__dirname, 'fixtures/layouts/**/*.html') })
        .then(layoutData => {
          expect(layoutData).to.be.an('Object')
            .and.to.contain.keys('default');
          expect(layoutData.default).to.be.a('string');
          done();
        });
    });
  });
  describe('parsing data', () => {
    it ('should correctly parse YAML data from files', done => {
      data.prepareDataData({
        data: path.join(__dirname, 'fixtures/data/**/*.yaml'),
        parseFn: (contents, path) => yaml.safeLoad(contents)
      }).then(dataData => {
        expect(dataData).to.be.an('Object')
          .and.to.contain.keys('another-data', 'sample-data');
        expect(dataData['another-data']).to.be.an('Object')
          .and.to.contain.keys('ding', 'forestry');
        done();
      });
    });
    it ('should correctly parse JSON data from files', done => {
      data.prepareDataData({
        data: path.join(__dirname, 'fixtures/data/**/*.json'),
        parseFn: (contents, path) => JSON.parse(contents)
      }).then(dataData => {
        expect(dataData).to.be.an('Object')
          .and.to.contain.keys('data-as-json');
        expect(dataData['data-as-json']).to.be.an('Object')
          .and.to.contain.keys('foo', 'fortunately');
        done();
      });
    });
  });
  describe('parsing pages', () => {
{'fraction_non_alphanumeric': 0.20193929173693087, 'fraction_numerical': 0.0, 'mean_word_length': 2.6339969372128635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '2039749', 'n_tokens_mistral': 739, 'n_tokens_neox': 725, 'n_words': 136}