<commit_before>const feedParser = require('tasks/feedParser.js'),
      fs = require('fs'),
      appFactory = require('appFactory.js'),
      {configureDatabaseModels} = require('test/helpers.js');

describe('feedParser', function () {

  before(function () {
    this.app = appFactory();

    this.server = this.app.listen(1234);

    this.app
      .get('/localFeed', (req, res) => {
        fs.readFile(__dirname + '/../assets/rogan-example-rss.xml', 'utf8', function(err, data) {
          if (err) {
            return console.log(err);
          }
          res.status(200).send(data);
        })
      });
  });

  after(function () {
    this.server.close();
  });

  describe('parseFeed function', function () {

    describe('when an invalid RSS URL is provided', function () {

      beforeEach(function (done) {
        feedParser.parseFeed('http://www.podverse.fm/fakepage')
          .then(done)
          .catch(err => {
            this.err = err;
            done();
          });
      });

      it('should reject with bad status code', function () {
        expect(this.err.message).to.equal('Bad status code');
      });

    });

    describe('when a valid RSS URL is provided', function () {

      beforeEach(function (done) {<commit_msg>openclose feed test server & increase mocha timeout<commit_after>const feedParser = require('tasks/feedParser.js'),
      fs = require('fs'),
      express = require('express'),
      {configureDatabaseModels} = require('test/helpers.js');

describe('feedParser', function () {

  before(function (done) {

    this.timeout = 5*1000; // allow 5 seconds before timeout

    this.app = express();

    this.server = this.app.listen(1234, done)

    this.app
      .get('/localFeed', (req, res) => {
        fs.readFile(__dirname + '/../assets/rogan-example-rss.xml', 'utf8', function(err, data) {
          if (err) {
            return console.log(err);
          }
          res.status(200).send(data);
        })
      });
  });

  after(function (done) {
    this.server.close(done);
  });

  describe('parseFeed function', function () {

    describe('when an invalid RSS URL is provided', function () {

      beforeEach(function (done) {
        feedParser.parseFeed('http://www.podverse.fm/fakepage')
          .then(done)
          .catch(err => {
            this.err = err;
            done();
          });
      });

      it('should reject with bad status code', function () {
        expect(this.err.message).to.equal('Bad status code');
      });

    });

    describe('when a valid RSS URL is provided', function () {

      beforeEach(function (done) {
{'fraction_non_alphanumeric': 0.16185410334346503, 'fraction_numerical': 0.008358662613981762, 'mean_word_length': 2.299498746867168, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, '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': '5191135', 'n_tokens_mistral': 794, 'n_tokens_neox': 750, 'n_words': 158}