2017-02-18 04:05:12 +08:00
|
|
|
"use strict";
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 04:05:12 +08:00
|
|
|
const path = require("path");
|
|
|
|
const should = require("should");
|
|
|
|
const sinon = require("sinon");
|
|
|
|
const ModuleDependencyError = require("../lib/ModuleDependencyError");
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 04:05:12 +08:00
|
|
|
describe("ModuleDependencyError", () => {
|
|
|
|
let env;
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 04:05:12 +08:00
|
|
|
beforeEach(() => env = {});
|
|
|
|
|
|
|
|
it("is a function", () => ModuleDependencyError.should.be.a.Function());
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 04:05:12 +08:00
|
|
|
describe("when new error created", () => {
|
|
|
|
beforeEach(() => {
|
2017-01-17 06:00:49 +08:00
|
|
|
env.error = new Error("Error Message");
|
|
|
|
env.moduleDependencyError = new ModuleDependencyError("myModule", env.error, "Location");
|
|
|
|
});
|
|
|
|
|
2017-02-18 04:05:12 +08:00
|
|
|
it("is an error", () => env.moduleDependencyError.should.be.an.Error());
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 04:05:12 +08:00
|
|
|
it("has a name property", () => env.moduleDependencyError.name.should.be.exactly("ModuleDependencyError"));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 05:00:47 +08:00
|
|
|
it("has a message property", () => env.moduleDependencyError.message.should.be.exactly("Location Error Message"));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 05:00:47 +08:00
|
|
|
it("has a details property", () => env.moduleDependencyError.details.should.containEql(path.join("test", "ModuleDependencyError.test.js:")));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 04:05:12 +08:00
|
|
|
it("has an origin property", () => env.moduleDependencyError.origin.should.be.exactly("myModule"));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2017-02-18 04:05:12 +08:00
|
|
|
it("has an error property", () => env.moduleDependencyError.error.should.be.exactly(env.error));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
|
|
|
});
|
|
|
|
});
|