<commit_before>chai = require 'chai' unless chai
Root = require '../lib/Root'

describe 'Solving a layout problem', ->
  describe 'with the Hello World layout', ->
    it 'should solve a single-item site', (done) ->
      page =
        config:
          color: 'red'
          layout: 'directed'
        items: [
          id: 'foo'
          content: [
            type: 'text'
            text: 'Foo'
          ]
        ,
          id: 'bar'
          content: [
            type: 'h1'
            text: 'Bar'
          ]
        ]
      t = Root()
      layout = require './fixtures/helloworld/index'
      t.deliver page
      layout t
      .then (c, d) ->
        chai.expect(c.namedPath()).to.eql [
          'color'
          'user'
          'red'
          'layout'
          'user'
          'directed'
          'sections'
        ]
        chai.expect(d).to.be.a 'string'
        clean = d.replace /\n/g, ''
        chai.expect(clean).to.equal '<section class="red directed"><article class="post right"><p>Foo</p></article><article class="post right"><h1>Bar</h1></article></section>'
        return done()<commit_msg>Tests/Solving: Use finally instead of then<commit_after>chai = require 'chai' unless chai
Root = require '../lib/Root'

describe 'Solving a layout problem', ->
  describe 'with the Hello World layout', ->
    it 'should solve a single-item site', (done) ->
      page =
        config:
          color: 'red'
          layout: 'directed'
        items: [
          id: 'foo'
          content: [
            type: 'text'
            text: 'Foo'
          ]
        ,
          id: 'bar'
          content: [
            type: 'h1'
            text: 'Bar'
          ]
        ]
      t = Root()
      layout = require './fixtures/helloworld/index'
      t.deliver page
      layout t
      .finally (c, d) ->
        chai.expect(d).to.be.a 'string'
        chai.expect(c.namedPath()).to.eql [
          'color'
          'user'
          'red'
          'layout'
          'user'
          'directed'
          'sections'
        ]
        clean = d.replace /\n/g, ''
        chai.expect(clean).to.equal '<section class="red directed"><article class="post right"><p>Foo</p></article><article class="post right"><h1>Bar</h1></article></section>'
        return done()

{'fraction_non_alphanumeric': 0.14615050021748585, 'fraction_numerical': 0.0026098303610265334, 'mean_word_length': 1.4945770065075923, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, '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': '2599010', 'n_tokens_mistral': 706, 'n_tokens_neox': 693, 'n_words': 168}