<commit_before>/* eslint max-nested-callbacks: 0*/
/* eslint no-unused-vars: 0*/
  // mocha's 'should' is not used
/* eslint max-len: 0 */
  // the html is partially longer than 80 characters
'use strict';

const chai = require('chai');
const should = chai.should();
const expect = chai.expect;
const keva = require('keva');
const noWhitespace = require('no-whitespace');
const express = require('express');
const frix = require('../lib/frix');
let opt = require('../lib/frix.conf.js');
opt.root = 'test/files/';

chai.use(require('chai-http'));

describe('frix', function() {
  describe('express handler', function() {
    it('should create valid function and html', function(done) {
      let expectedHtml = noWhitespace(`
        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="utf-8"/>
            <title>Woody</title>
          </head>
          <body>
            <article>
              <header>
                <h1>Tree</h1>
                <h1>Baum</h1>
                <p>written by <a href="https://simple.wikipedia.org/wiki/Tree">Wikipedia</a></p>
              </header>
              <p>A tree is a tall plant with a trunk and branches made of wood.</p>
            </article>
          </body>
        </html>
      `);
      let app = express();
      frix.render().then(requestHandler => {
        app.use(requestHandler);
        chai.request(app).get('/page1').end((err, res) => {
          if (err) throw err;
          expect(noWhitespace(res.text)).to.equal(expectedHtml);
          done();
        });
      }, err => console.log(err));
    });

    it('should not return anything when url is invalid', function(done) {
      let app = express();
      frix.render().then(requestHandler => {
        app.use(requestHandler);
        chai.request(app).get('/invalid').end((_, res) => {
          expect(res).to.have.status(404);
          done();
        });
      });
    });
  });

  describe('loops', function() {
    it('should be executed', function(done) {
      let expectedHtml = noWhitespace(`
        <article>
          <header>
            <h1>Tree</h1>
            <h1>Baum</h1>
            <p>written by <a href="https://simple.wikipedia.org/wiki/Tree">Wikipedia</a></p>
          </header>
          <p>A tree is a tall plant with a trunk and branches made of wood.</p>
        </article>
        <br/>
        <cite>Insert smart-ass quote here.</cite>
        <br/>
      `);
      let app = express();
      opt.key = 'loop-test.json';
      frix.render().then(requestHandler => {<commit_msg>rewrote test html with classes<commit_after>/* eslint max-nested-callbacks: 0*/
/* eslint no-unused-vars: 0*/
  // mocha's 'should' is not used
/* eslint max-len: 0 */
  // the html is partially longer than 80 characters
'use strict';

const chai = require('chai');
const should = chai.should();
const expect = chai.expect;
const keva = require('keva');
const noWhitespace = require('no-whitespace');
const express = require('express');
const frix = require('../lib/frix');
let opt = require('../lib/frix.conf.js');
opt.root = 'test/files/';

chai.use(require('chai-http'));

describe('frix', function() {
  describe('express handler', function() {
    it('should create valid function and html', function(done) {
      let expectedHtml = noWhitespace(`
        <!DOCTYPE html>
        <html>
          <head>
            <meta charset="utf-8"/>
            <title>Woody</title>
          </head>
          <body>
            <article class="article">
              <header class="header">
                <h1 class="heading">Tree</h1>
                <h1 class="heading">Baum</h1>
                <p class="author">written by <a href="https://simple.wikipedia.org/wiki/Tree">Wikipedia</a></p>
              </header>
              <p>A tree is a tall plant with a trunk and branches made of wood.</p>
            </article>
          </body>
        </html>
      `);
      let app = express();
      frix.render().then(requestHandler => {
        app.use(requestHandler);
        chai.request(app).get('/page1').end((err, res) => {
          if (err) throw err;
          expect(noWhitespace(res.text)).to.equal(expectedHtml);
          done();
        });
      }, err => console.log(err));
    });

    it('should not return anything when url is invalid', function(done) {
      let app = express();
      frix.render().then(requestHandler => {
        app.use(requestHandler);
        chai.request(app).get('/invalid').end((_, res) => {
          expect(res).to.have.status(404);
          done();
        });
      });
    });
  });

  describe('loops', function() {
    it('should be executed', function(done) {
      let expectedHtml = noWhitespace(`
        <article class="article">
          <header class="header">
            <h1 class="heading">Tree</h1>
            <h1 class="heading">Baum</h1>
            <p class="author">written by <a href="https://simple.wikipedia.org/wiki/Tree">Wikipedia</a></p>
          </header>
          <p>A tree is a tall plant with a trunk and branches made of wood.</p>
        </article>
        <br/>
        <cite class="quote">Insert smart-ass quote here.</cite>
        <br/>
      `);
      let app = express();
      opt.key = 'loop-test.json';
      frix.render().then(requestHandler => {
{'fraction_non_alphanumeric': 0.16914953799736, 'fraction_numerical': 0.006788610220629833, 'mean_word_length': 2.12, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 99, 'https://': 4, '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': '3893521', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1592, 'n_words': 375}