Skip to content

Commit

Permalink
[api test] Added winston.Container.has and associated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
indexzero committed Sep 13, 2011
1 parent c866bac commit f1b418c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/winston/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ Container.prototype.get = Container.prototype.add = function (id, options) {
return this.loggers[id];
};

//
// ### function close (id)
// #### @id {string} **Optional** Id of the Logger instance to find
// Returns a boolean value indicating if this instance
// has a logger with the specified `id`.
//
Container.prototype.has = function (id) {
return !!this.loggers[id];
};

//
// ### function close (id)
// #### @id {string} **Optional** Id of the Logger instance to close
Expand Down
11 changes: 11 additions & 0 deletions test/container-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ vows.describe('winston/container').addBatch({
assert.isTrue(existing === logger);
}
},
"the has() method": {
topic: function (logger, container) {
this.callback.apply(this, arguments);
},
"should indicate `default-test` logger exists": function (existing, container) {
assert.isTrue(container.has('default-test'));
},
"should indicate `not-has` logger doesnt exists": function (existing, container) {
assert.isFalse(container.has('not-has'));
}
},
"the close() method": {
topic: function (logger, container) {
this.callback.apply(this, arguments);
Expand Down

0 comments on commit f1b418c

Please sign in to comment.