<commit_before>"use strict";

var chai = require("chai");
var expect = chai.expect;

var MiddlewareJs = require("../lib/middleware");

// describing the logger variable instantiated above.
describe("Middleware.js with Errors", function() {

  it("should not load anything when not providing options", function(done) {
    var conf = MiddlewareJs.instance().load();
    expect(conf).to.be.undefined;

    done();
  });

  it("should throw an error when giving a non-existing middleware", function(done) {
    try {
      MiddlewareJs.instance().load("does/not/exist");

    } catch (middlewareNotLoaded) {
      expect(middlewareNotLoaded).not.be.be.null;
      expect(middlewareNotLoaded.message).to.equal("Cannot load middleware 'does/not/exist'");
    }

    done();
  });

});
<commit_msg>Issue #1: Improving negative tests: dot notation, paths, new error msg<commit_after>"use strict";

var chai = require("chai");
var expect = chai.expect;

var MiddlewareJs = require("../lib/middleware");

var path = require("path");
var currentDir = path.resolve(__dirname, "..");

// describing the logger variable instantiated above.
describe("Middleware.js with Errors", function() {

  it("should not load anything when not providing options", function(done) {
    var conf = MiddlewareJs.require();
    expect(conf).to.be.undefined;

    done();
  });

  it("should throw an error when giving a non-existing middleware using path/to/middleware", function(done) {
    try {
      MiddlewareJs.require("does/not/exist");

    } catch (middlewareNotLoaded) {
      expect(middlewareNotLoaded).not.be.be.null;

      expect(middlewareNotLoaded.message).to.equal("Cannot find middleware '" + currentDir + "/does/not/exist'");
    }

    done();
  });

  it("should throw an error when giving a non-existing middleware using dot.notation.to.middleware", function(done) {
    try {
      MiddlewareJs.require("com.github.service");

    } catch (middlewareNotLoaded) {
      expect(middlewareNotLoaded).not.be.be.null;
      expect(middlewareNotLoaded.message).to.equal("Cannot find middleware '" + currentDir + "/com/github/service'");
    }

    done();
  });

});

{'fraction_non_alphanumeric': 0.1461038961038961, 'fraction_numerical': 0.00046382189239332097, 'mean_word_length': 3.858108108108108, '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': '7635363', 'n_tokens_mistral': 648, 'n_tokens_neox': 629, 'n_words': 152}