<commit_before>var $http = require('http-as-promised');
var harvester = require('../lib/harvester');
var baseUrl = 'http://localhost:' + 8005;
var chai = require('chai');
var expect = chai.expect;
var ess = require('event-source-stream');
var _ = require('lodash');
var config = require('./config.js');
var seeder = require('./seeder.js');
var Joi = require('joi');

describe('EventSource implementation for resource changes', function () {

    var harvesterApp;
    describe('Server Sent Events', function () {
        this.timeout(10000);
        var lastEventId;
        var lastDataId;

        before(function () {
            var options = {
                adapter: 'mongodb',
                connectionString: config.harvester.options.connectionString,
                db: 'test',
                inflect: true,
                oplogConnectionString: config.harvester.options.oplogConnectionString
            };

            harvesterApp = harvester(options).resource('book', {
                title: Joi.string(),
                author: Joi.string()
            });

            harvesterApp.listen(8005);

            return seeder(harvesterApp, baseUrl).dropCollections('books')
        });

        describe('When I post to the newly created resource', function () {
            it('Then I should receive a change event with data but not the one before it', function (done) {
                var that = this;
<commit_msg>increasing test duration for eventual slow machine<commit_after>var $http = require('http-as-promised');
var harvester = require('../lib/harvester');
var baseUrl = 'http://localhost:' + 8005;
var chai = require('chai');
var expect = chai.expect;
var ess = require('event-source-stream');
var _ = require('lodash');
var config = require('./config.js');
var seeder = require('./seeder.js');
var Joi = require('joi');

describe('EventSource implementation for resource changes', function () {

    var harvesterApp;
    describe('Server Sent Events', function () {
        this.timeout(20000);
        var lastEventId;
        var lastDataId;

        before(function () {
            var options = {
                adapter: 'mongodb',
                connectionString: config.harvester.options.connectionString,
                db: 'test',
                inflect: true,
                oplogConnectionString: config.harvester.options.oplogConnectionString
            };

            harvesterApp = harvester(options).resource('book', {
                title: Joi.string(),
                author: Joi.string()
            });

            harvesterApp.listen(8005);

            return seeder(harvesterApp, baseUrl).dropCollections('books')
        });

        describe('When I post to the newly created resource', function () {
            it('Then I should receive a change event with data but not the one before it', function (done) {
                var that = this;

{'fraction_non_alphanumeric': 0.12237882433826057, 'fraction_numerical': 0.0089377793056033, 'mean_word_length': 2.3409873708381173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '896643', 'n_tokens_mistral': 810, 'n_tokens_neox': 733, 'n_words': 204}