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");
|
2017-11-15 21:08:11 +08:00
|
|
|
require("should");
|
2017-02-18 04:05:12 +08:00
|
|
|
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
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
beforeEach(() => (env = {}));
|
2017-02-18 04:05:12 +08:00
|
|
|
|
|
|
|
|
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");
|
2018-02-25 09:00:20 +08:00
|
|
|
env.moduleDependencyError = new ModuleDependencyError(
|
|
|
|
|
"myModule",
|
|
|
|
|
env.error,
|
|
|
|
|
"Location"
|
|
|
|
|
);
|
2017-01-17 06:00:49 +08:00
|
|
|
});
|
|
|
|
|
|
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
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
it("has a name property", () =>
|
|
|
|
|
env.moduleDependencyError.name.should.be.exactly(
|
|
|
|
|
"ModuleDependencyError"
|
|
|
|
|
));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
it("has a message property", () =>
|
|
|
|
|
env.moduleDependencyError.message.should.be.exactly(
|
|
|
|
|
"Location Error Message"
|
|
|
|
|
));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
it("has a details property", () =>
|
|
|
|
|
env.moduleDependencyError.details.should.containEql(
|
|
|
|
|
path.join("test", "ModuleDependencyError.unittest.js:")
|
|
|
|
|
));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
it("has an origin property", () =>
|
|
|
|
|
env.moduleDependencyError.origin.should.be.exactly("myModule"));
|
2017-01-17 06:00:49 +08:00
|
|
|
|
2018-02-25 09:00:20 +08:00
|
|
|
it("has an error property", () =>
|
|
|
|
|
env.moduleDependencyError.error.should.be.exactly(env.error));
|
2017-01-17 06:00:49 +08:00
|
|
|
});
|
|
|
|
|
});
|