<commit_before>  /*****************************************************
 * Internal tests
 * What are internal tests?
 * As this is a npm package, it should be tested from
 * a package context, so I'll use "interal" preffix
 * for tests which are NOT using the npm tarball pack
 * For all others, the test should obviously include
 * something like:
 * let md = require('t-motion-detector');
 *****************************************************/

let chai = require('chai');
let chaiAsPromised = require("chai-as-promised");
let should = chai.should();
let fs = require('fs');
let ent = require('../Entities.js');
let ext = require('../Extensions.js');
let main = require('../main.js');
let events = require('events');
//Chai will use promises for async events
chai.use(chaiAsPromised);

before(function(done) {
  done();
});

after(function(done) {
  // here you can clear fixtures, etc.
  if (fs.existsSync('./_local.js')) {
    //fs.rename('./_local.js', './local.js', function (err) {
      //Nothing I can do here
      //if (err) throw err;
    //});
  }
  done();
});

describe("When a new LoginDetector,", function() {
  it('It should detect if a user has failed to login via ssh', function (done) {
    //Prepare
    main.Reset();
    let alternativeConfig = new main.Config("/test/config_test13.js");
    main.StartWithConfig(alternativeConfig, (e, d, n, f)=>{

      n[0].on('pushedNotification', function(message, text, data){
        //Contrary to Motion Detector Filters, Environment filters prevent state to change
        data.newState.stdout.data.should.equal(process.cwd()+'\n');
        data.newState.should.eql({});
        done();
      });
    });
    //Will not test if successfully logged in
  });
});

describe("When a new Simple Command is created for an environment with a Filter,", function() {
  it('should notify if cannot reach a certain server (via Regex Expression match)', function (done) {
    //Prepare<commit_msg>Adjusting one unit test to local as it is not viable to run from travis<commit_after>  /*****************************************************
 * Internal tests
 * What are internal tests?
 * As this is a npm package, it should be tested from
 * a package context, so I'll use "interal" preffix
 * for tests which are NOT using the npm tarball pack
 * For all others, the test should obviously include
 * something like:
 * let md = require('t-motion-detector');
 *****************************************************/

let chai = require('chai');
let chaiAsPromised = require("chai-as-promised");
let should = chai.should();
let fs = require('fs');
let ent = require('../Entities.js');
let ext = require('../Extensions.js');
let main = require('../main.js');
let events = require('events');
//Chai will use promises for async events
chai.use(chaiAsPromised);

before(function(done) {
  done();
});

after(function(done) {
  // here you can clear fixtures, etc.
  if (fs.existsSync('./_local.js')) {
    //fs.rename('./_local.js', './local.js', function (err) {
      //Nothing I can do here
      //if (err) throw err;
    //});
  }
  done();
});

describe("When a new LoginDetector,", function() {
  it('It should detect if a user has failed to login via ssh', function (done) {
    //Prepare
    main.Reset();
    let alternativeConfig = new main.Config("/test/config_test13.js");
    main.StartWithConfig(alternativeConfig, (e, d, n, f)=>{

      n[0].on('pushedNotification', function(message, text, data){
        //Contrary to Motion Detector Filters, Environment filters prevent state to change
        data.newState.stdout.data.should.equal(process.cwd()+'\n');
        data.newState.should.eql({});
        done();
      });
    });
    //Will not test if successfully logged in
  });
});
describe("When detecting a change", function() {
  it('Should send to Slack old files (3 files) in the folder when FileDetector "sendOld = true"', function(done) {
    this.timeout(4000);
    main.Reset();

    let alternativeConfig = new main.Config("/test/config_test16.js");
    let count = 0;
    
    main.StartWithConfig(alternativeConfig, (e, d, n, f)=>{
      let sConfig = new main.Config();
      let slackNotifier1 = new ext.SlackNotifier("My Slack notifier", sConfig.slackHook(), sConfig.slackAuth());
      slackNotifier1.on('pushedNotification', function(message, text, data){
        text.should.contain("received Notification received from: 'File Detector 16 - should notify'");
        console.log("Notified!");
        count++;
        if (count == 2){
          done();
        }
      });

      //Raspistill Notifier
      n[0].on('pushedNotification', function(message, text, data){
        console.log(text);
      });
      main.AddNotifier(slackNotifier1);

      //Act
      d[0].send(9, e);
    });
  });
});

describe("When a new Simple Command is created for an environment with a Filter,", function() {
  it('should notify if cannot reach a certain server (via Regex Expression match)', function (done) {
    //Prepare
{'fraction_non_alphanumeric': 0.18527410964385754, 'fraction_numerical': 0.004601840736294518, 'mean_word_length': 3.4514692787177204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '3809221', 'n_tokens_mistral': 1492, 'n_tokens_neox': 1446, 'n_words': 472}