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"); | "use strict"; | ||||||
| var should = require("should"); |  | ||||||
| var sinon = require("sinon"); |  | ||||||
| var ModuleDependencyError = require("../lib/ModuleDependencyError"); |  | ||||||
| 
 | 
 | ||||||
| describe("ModuleDependencyError", function() { | const path = require("path"); | ||||||
| 	var env; | const should = require("should"); | ||||||
|  | const sinon = require("sinon"); | ||||||
|  | const ModuleDependencyError = require("../lib/ModuleDependencyError"); | ||||||
| 
 | 
 | ||||||
| 	beforeEach(function() { | describe("ModuleDependencyError", () => { | ||||||
| 		env = {}; | 	let env; | ||||||
| 	}); |  | ||||||
| 
 | 
 | ||||||
| 	it("is a function", function() { | 	beforeEach(() => env = {}); | ||||||
| 		ModuleDependencyError.should.be.a.Function(); |  | ||||||
| 	}); |  | ||||||
| 
 | 
 | ||||||
| 	describe("when new error created", function() { | 	it("is a function", () => ModuleDependencyError.should.be.a.Function()); | ||||||
| 		beforeEach(function() { | 
 | ||||||
|  | 	describe("when new error created", () => { | ||||||
|  | 		beforeEach(() => { | ||||||
| 			env.error = new Error("Error Message"); | 			env.error = new Error("Error Message"); | ||||||
| 			env.moduleDependencyError = new ModuleDependencyError("myModule", env.error, "Location"); | 			env.moduleDependencyError = new ModuleDependencyError("myModule", env.error, "Location"); | ||||||
| 		}); | 		}); | ||||||
| 
 | 
 | ||||||
| 		it("is an error", function() { | 		it("is an error", () => env.moduleDependencyError.should.be.an.Error()); | ||||||
| 			env.moduleDependencyError.should.be.an.Error(); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("has a name property", function() { | 		it("has a name property", () => env.moduleDependencyError.name.should.be.exactly("ModuleDependencyError")); | ||||||
| 			env.moduleDependencyError.name.should.be.exactly("ModuleDependencyError"); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("has a message property", function() { | 		it("has a message property", () => env.moduleDependencyError.message.should.be.exactly("Location Error Message")); | ||||||
| 			env.moduleDependencyError.message.should.be.exactly("Location Error Message"); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("has a details property", function() { | 		it("has a details property", () => env.moduleDependencyError.details.should.containEql(path.join("test", "ModuleDependencyError.test.js:"))); | ||||||
| 			env.moduleDependencyError.details.should.containEql(path.join("test", "ModuleDependencyError.test.js:")); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("has an origin property", function() { | 		it("has an origin property", () => env.moduleDependencyError.origin.should.be.exactly("myModule")); | ||||||
| 			env.moduleDependencyError.origin.should.be.exactly("myModule"); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("has an error property", function() { | 		it("has an error property", () => env.moduleDependencyError.error.should.be.exactly(env.error)); | ||||||
| 			env.moduleDependencyError.error.should.be.exactly(env.error); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 	}); | 	}); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | @ -1,36 +1,26 @@ | ||||||
| var should = require("should"); | "use strict"; | ||||||
| var sinon = require("sinon"); |  | ||||||
| var NullDependency = require("../lib/dependencies/NullDependency"); |  | ||||||
| 
 | 
 | ||||||
| describe("NullDependency", function() { | const should = require("should"); | ||||||
| 	var env; | const sinon = require("sinon"); | ||||||
|  | const NullDependency = require("../lib/dependencies/NullDependency"); | ||||||
| 
 | 
 | ||||||
| 	beforeEach(function() { | describe("NullDependency", () => { | ||||||
| 		env = {}; | 	let env; | ||||||
| 	}); |  | ||||||
| 
 | 
 | ||||||
| 	it("is a function", function() { | 	beforeEach(() => env = {}); | ||||||
| 		NullDependency.should.be.a.Function(); |  | ||||||
| 	}); |  | ||||||
| 
 | 
 | ||||||
| 	describe("when created", function() { | 	it("is a function", () => NullDependency.should.be.a.Function()); | ||||||
| 		beforeEach(function() { |  | ||||||
| 			env.nullDependency = new NullDependency(); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("has a null type", function() { | 	describe("when created", () => { | ||||||
| 			env.nullDependency.type.should.be.exactly("null"); | 		beforeEach(() => env.nullDependency = new NullDependency()); | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("is not an equal resource", function() { | 		it("has a null type", () => env.nullDependency.type.should.be.exactly("null")); | ||||||
| 			env.nullDependency.isEqualResource().should.be.False(); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("has update hash function", function() { | 		it("is not an equal resource", () => env.nullDependency.isEqualResource().should.be.False()); | ||||||
| 			env.nullDependency.updateHash.should.be.Function(); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		it("does not update hash", function() { | 		it("has update hash function", () => env.nullDependency.updateHash.should.be.Function()); | ||||||
|  | 
 | ||||||
|  | 		it("does not update hash", () => { | ||||||
| 			const hash = { | 			const hash = { | ||||||
| 				update: sinon.stub() | 				update: sinon.stub() | ||||||
| 			}; | 			}; | ||||||
|  | @ -39,19 +29,13 @@ describe("NullDependency", function() { | ||||||
| 		}); | 		}); | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	describe("Template", function() { | 	describe("Template", () => { | ||||||
| 		it("is a function", function() { | 		it("is a function", () => NullDependency.Template.should.be.a.Function()); | ||||||
| 			NullDependency.Template.should.be.a.Function(); |  | ||||||
| 		}); |  | ||||||
| 
 | 
 | ||||||
| 		describe("when created", function() { | 		describe("when created", () => { | ||||||
| 			beforeEach(function() { | 			beforeEach(() => env.nullDependencyTemplate = new NullDependency.Template()); | ||||||
| 				env.nullDependencyTemplate = new NullDependency.Template(); |  | ||||||
| 			}); |  | ||||||
| 
 | 
 | ||||||
| 			it("has apply function", function() { | 			it("has apply function", () => env.nullDependencyTemplate.apply.should.be.Function()); | ||||||
| 				env.nullDependencyTemplate.apply.should.be.Function(); |  | ||||||
| 			}); |  | ||||||
| 		}); | 		}); | ||||||
| 	}); | 	}); | ||||||
| }); | }); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue