The register method should return existing modules

This commit is contained in:
Daniel Lamb 2015-02-20 11:25:31 -08:00
parent b17542061b
commit ccebab4cc2
4 changed files with 32 additions and 1 deletions

13
.editorconfig Normal file
View File

@ -0,0 +1,13 @@
# http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
trim_trailing_whitespace = false

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/node_modules/ /node_modules/
npm-debug.log npm-debug.log
/coverage/ /coverage/
.idea/

View File

@ -35,7 +35,7 @@ var Registry = module.exports = {
register: function(module) { register: function(module) {
if (this.data[module]) { if (this.data[module]) {
return; return this.data[module].module;
} }
var pkg; var pkg;

View File

@ -34,5 +34,22 @@ describe("Registry", function() {
} }
}); });
}); });
context("when the module already exists", function() {
it("returns the module", function() {
expect(Registry.data).to.be.eql({});
var result = Registry.register(path);
// should register the module and return it
expect(result).to.be.eql(mod);
result = Registry.register(path);
// should just return the existing module
expect(result).to.be.eql(mod);
});
});
}); });
}); });