mirror of https://github.com/webpack/webpack.git
				
				
				
			Merge pull request #4304 from sergiorojasa/refactor-test-ModuleDependencyError
Refactor(ES6): ModuleDependencyError.test.js
This commit is contained in:
		
						commit
						84457bda2a
					
				|  | @ -1,48 +1,34 @@ | |||
| var path = require("path"); | ||||
| var should = require("should"); | ||||
| var sinon = require("sinon"); | ||||
| var ModuleDependencyError = require("../lib/ModuleDependencyError"); | ||||
| "use strict"; | ||||
| 
 | ||||
| describe("ModuleDependencyError", function() { | ||||
| 	var env; | ||||
| const path = require("path"); | ||||
| const should = require("should"); | ||||
| const sinon = require("sinon"); | ||||
| const ModuleDependencyError = require("../lib/ModuleDependencyError"); | ||||
| 
 | ||||
| 	beforeEach(function() { | ||||
| 		env = {}; | ||||
| 	}); | ||||
| describe("ModuleDependencyError", () => { | ||||
| 	let env; | ||||
| 
 | ||||
| 	it("is a function", function() { | ||||
| 		ModuleDependencyError.should.be.a.Function(); | ||||
| 	}); | ||||
| 	beforeEach(() => env = {}); | ||||
| 
 | ||||
| 	describe("when new error created", function() { | ||||
| 		beforeEach(function() { | ||||
| 	it("is a function", () => ModuleDependencyError.should.be.a.Function()); | ||||
| 
 | ||||
| 	describe("when new error created", () => { | ||||
| 		beforeEach(() => { | ||||
| 			env.error = new Error("Error Message"); | ||||
| 			env.moduleDependencyError = new ModuleDependencyError("myModule", env.error, "Location"); | ||||
| 		}); | ||||
| 
 | ||||
| 		it("is an error", function() { | ||||
| 			env.moduleDependencyError.should.be.an.Error(); | ||||
| 		}); | ||||
| 		it("is an error", () => env.moduleDependencyError.should.be.an.Error()); | ||||
| 
 | ||||
| 		it("has a name property", function() { | ||||
| 			env.moduleDependencyError.name.should.be.exactly("ModuleDependencyError"); | ||||
| 		}); | ||||
| 		it("has a name property", () => env.moduleDependencyError.name.should.be.exactly("ModuleDependencyError")); | ||||
| 
 | ||||
| 		it("has a message property", function() { | ||||
| 			env.moduleDependencyError.message.should.be.exactly("Location Error Message"); | ||||
| 		}); | ||||
| 		it("has a message property", () => env.moduleDependencyError.message.should.be.exactly("Location Error Message")); | ||||
| 
 | ||||
| 		it("has a details property", function() { | ||||
| 			env.moduleDependencyError.details.should.containEql(path.join("test", "ModuleDependencyError.test.js:")); | ||||
| 		}); | ||||
| 		it("has a details property", () => env.moduleDependencyError.details.should.containEql(path.join("test", "ModuleDependencyError.test.js:"))); | ||||
| 
 | ||||
| 		it("has an origin property", function() { | ||||
| 			env.moduleDependencyError.origin.should.be.exactly("myModule"); | ||||
| 		}); | ||||
| 		it("has an origin property", () => env.moduleDependencyError.origin.should.be.exactly("myModule")); | ||||
| 
 | ||||
| 		it("has an error property", function() { | ||||
| 			env.moduleDependencyError.error.should.be.exactly(env.error); | ||||
| 		}); | ||||
| 		it("has an error property", () => env.moduleDependencyError.error.should.be.exactly(env.error)); | ||||
| 
 | ||||
| 	}); | ||||
| }); | ||||
|  |  | |||
|  | @ -1,36 +1,26 @@ | |||
| var should = require("should"); | ||||
| var sinon = require("sinon"); | ||||
| var NullDependency = require("../lib/dependencies/NullDependency"); | ||||
| "use strict"; | ||||
| 
 | ||||
| describe("NullDependency", function() { | ||||
| 	var env; | ||||
| const should = require("should"); | ||||
| const sinon = require("sinon"); | ||||
| const NullDependency = require("../lib/dependencies/NullDependency"); | ||||
| 
 | ||||
| 	beforeEach(function() { | ||||
| 		env = {}; | ||||
| 	}); | ||||
| describe("NullDependency", () => { | ||||
| 	let env; | ||||
| 
 | ||||
| 	it("is a function", function() { | ||||
| 		NullDependency.should.be.a.Function(); | ||||
| 	}); | ||||
| 	beforeEach(() => env = {}); | ||||
| 
 | ||||
| 	describe("when created", function() { | ||||
| 		beforeEach(function() { | ||||
| 			env.nullDependency = new NullDependency(); | ||||
| 		}); | ||||
| 	it("is a function", () => NullDependency.should.be.a.Function()); | ||||
| 
 | ||||
| 		it("has a null type", function() { | ||||
| 			env.nullDependency.type.should.be.exactly("null"); | ||||
| 		}); | ||||
| 	describe("when created", () => { | ||||
| 		beforeEach(() => env.nullDependency = new NullDependency()); | ||||
| 
 | ||||
| 		it("is not an equal resource", function() { | ||||
| 			env.nullDependency.isEqualResource().should.be.False(); | ||||
| 		}); | ||||
| 		it("has a null type", () => env.nullDependency.type.should.be.exactly("null")); | ||||
| 
 | ||||
| 		it("has update hash function", function() { | ||||
| 			env.nullDependency.updateHash.should.be.Function(); | ||||
| 		}); | ||||
| 		it("is not an equal resource", () => env.nullDependency.isEqualResource().should.be.False()); | ||||
| 
 | ||||
| 		it("does not update hash", function() { | ||||
| 		it("has update hash function", () => env.nullDependency.updateHash.should.be.Function()); | ||||
| 
 | ||||
| 		it("does not update hash", () => { | ||||
| 			const hash = { | ||||
| 				update: sinon.stub() | ||||
| 			}; | ||||
|  | @ -39,19 +29,13 @@ describe("NullDependency", function() { | |||
| 		}); | ||||
| 	}); | ||||
| 
 | ||||
| 	describe("Template", function() { | ||||
| 		it("is a function", function() { | ||||
| 			NullDependency.Template.should.be.a.Function(); | ||||
| 		}); | ||||
| 	describe("Template", () => { | ||||
| 		it("is a function", () => NullDependency.Template.should.be.a.Function()); | ||||
| 
 | ||||
| 		describe("when created", function() { | ||||
| 			beforeEach(function() { | ||||
| 				env.nullDependencyTemplate = new NullDependency.Template(); | ||||
| 			}); | ||||
| 		describe("when created", () => { | ||||
| 			beforeEach(() => env.nullDependencyTemplate = new NullDependency.Template()); | ||||
| 
 | ||||
| 			it("has apply function", function() { | ||||
| 				env.nullDependencyTemplate.apply.should.be.Function(); | ||||
| 			}); | ||||
| 			it("has apply function", () => env.nullDependencyTemplate.apply.should.be.Function()); | ||||
| 		}); | ||||
| 	}); | ||||
| }); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue