<commit_before>/*global expect, it, beforeEach, afterEach */

'use strict';

var expect = require('chai').expect
  , P = require('bluebird')
  , fs = P.promisifyAll(require('fs'))
  , sh = require('shelljs')
  , sinon = require('sinon')
  , cheerio = require('cheerio')
  , build = require('../index.js').build
  , utf8 = {encoding: 'utf8'};

var cwdSave = sh.pwd()
  , stello;

beforeEach(function(done) {
  // Stello templates should expect cwd to be the doc root
  sh.mkdir(__dirname + '/www');
  sh.cd(__dirname + '/www');

  // Only build the stello stub once
  return stello ? done() :
    P.all([
      fs.readFileAsync('../data/pages/1.json', utf8),
      fs.readFileAsync('../data/pages/2.json', utf8),
      fs.readFileAsync('../data/posts/1.json', utf8),
      fs.readFileAsync('../data/posts/2.json', utf8),
      fs.readFileAsync('../data/posts/3.json', utf8)
    ])
    .then(function(results) {
      stello = {};
      stello.getCards = sinon.stub();
      stello.getCards.withArgs('Pages').returns(results.slice(0,2));
      stello.getCards.withArgs('Posts').returns(results.slice(2));
      stello.getCards.returns(results);
      done();
    });
});

beforeEach(function(done) {
  build(stello, done);
});

afterEach(function() {
  sh.rm('-rf', __dirname + '/www');
  sh.cd(cwdSave);
});

describe('build', function() {
  it('should create a home page from first pages card', function() {
    // ...
  });

  it('should create pages', function() {
    // ...
  });

  it('should create posts', function() {
    // ...
  });

  it('should create a search page', function() {
    // ...
  });

  it('should overwrite existing files', function() {
    // ...
  });
});<commit_msg>test: Add test for pages creation<commit_after>/*global expect, it, beforeEach, afterEach */

'use strict';

var expect = require('chai').expect
  , P = require('bluebird')
  , fs = P.promisifyAll(require('fs'))
  , sh = require('shelljs')
  , sinon = require('sinon')
  , cheerio = require('cheerio')
  , build = require('../index.js').build
  , utf8 = {encoding: 'utf8'};

var cwdSave = sh.pwd()
  , stello;

beforeEach(function(done) {
  // Stello templates should expect cwd to be the doc root
  sh.mkdir(__dirname + '/www');
  sh.cd(__dirname + '/www');

  // Only build the stello stub once
  return stello ? done() :
    P.all([
      fs.readFileAsync('../data/pages/1.json', utf8),
      fs.readFileAsync('../data/pages/2.json', utf8),
      fs.readFileAsync('../data/posts/1.json', utf8),
      fs.readFileAsync('../data/posts/2.json', utf8),
      fs.readFileAsync('../data/posts/3.json', utf8)
    ])
    .then(function(results) {
      stello = {};
      stello.getCards = sinon.stub();
      stello.getCards.withArgs('Pages').returns(results.slice(0,2));
      stello.getCards.withArgs('Posts').returns(results.slice(2));
      stello.getCards.returns(results);
      done();
    });
});

beforeEach(function(done) {
  build(stello, done);
});

afterEach(function() {
  sh.rm('-rf', __dirname + '/www');
  sh.cd(cwdSave);
});

describe('build', function() {
  it('should create a home page from first pages card', function() {
    // ...
  });

  it('should create pages', function(done) {
    P.props({
      one: fs.existsAsync('first-page/index.html'),
      two: fs.existsAsync('second-page/index.html')
    })
    .then(function(hasPages) {
      expect(hasPages.one).to.equal(true);
      expect(hasPages.two).to.equal(true);
    });
  });

  it('should create posts', function() {
    // ...
  });

  it('should create a search page', function() {
    // ...
  });

  it('should overwrite existing files', function() {
    // ...
  });
});
{'fraction_non_alphanumeric': 0.2030095759233926, 'fraction_numerical': 0.008207934336525308, 'mean_word_length': 2.9567099567099566, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '1259968', 'n_tokens_mistral': 1262, 'n_tokens_neox': 1253, 'n_words': 235}