|
| 1 | +var path = require("path"); |
| 2 | +var should = require("should"); |
| 3 | +var sinon = require("sinon"); |
| 4 | +var ModuleDependencyError = require("../lib/ModuleDependencyError"); |
| 5 | + |
| 6 | +describe("ModuleDependencyError", function() { |
| 7 | + var env; |
| 8 | + |
| 9 | + beforeEach(function() { |
| 10 | + env = {}; |
| 11 | + }); |
| 12 | + |
| 13 | + it("is a function", function() { |
| 14 | + ModuleDependencyError.should.be.a.Function(); |
| 15 | + }); |
| 16 | + |
| 17 | + describe("when new error created", function() { |
| 18 | + beforeEach(function() { |
| 19 | + env.error = new Error("Error Message"); |
| 20 | + env.moduleDependencyError = new ModuleDependencyError("myModule", env.error, "Location"); |
| 21 | + }); |
| 22 | + |
| 23 | + it("is an error", function() { |
| 24 | + env.moduleDependencyError.should.be.an.Error(); |
| 25 | + }); |
| 26 | + |
| 27 | + it("has a name property", function() { |
| 28 | + env.moduleDependencyError.name.should.be.exactly("ModuleDependencyError"); |
| 29 | + }); |
| 30 | + |
| 31 | + it("has a message property", function() { |
| 32 | + env.moduleDependencyError.message.should.be.exactly("Location Error Message"); |
| 33 | + }); |
| 34 | + |
| 35 | + it("has a details property", function() { |
| 36 | + env.moduleDependencyError.details.should.containEql(path.join("test", "ModuleDependencyError.test.js:")); |
| 37 | + }); |
| 38 | + |
| 39 | + it("has an origin property", function() { |
| 40 | + env.moduleDependencyError.origin.should.be.exactly("myModule"); |
| 41 | + }); |
| 42 | + |
| 43 | + it("has an error property", function() { |
| 44 | + env.moduleDependencyError.error.should.be.exactly(env.error); |
| 45 | + }); |
| 46 | + |
| 47 | + }); |
| 48 | +}); |
0 commit comments