Skip to content

Commit

Permalink
deepEqual should expose equality of instances
Browse files Browse the repository at this point in the history
  • Loading branch information
williamkapke committed Mar 30, 2015
1 parent 40a70bc commit b49356a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions objectid.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ function ObjectID(arg) {
}

Object.defineProperty(this, "id", {
enumerable: true,
get: function() { return String.fromCharCode.apply(this, buf); }
});
Object.defineProperty(this, "str", {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bson-objectid",
"version": "1.0.2",
"version": "1.1.0",
"description": "Construct ObjectIDs without the mongodb driver or bson module",
"main": "objectid.js",
"directories": {
Expand Down
15 changes: 15 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ describe("ObjectIDs", function() {
ObjectID.isValid("54495-ad94c934721ede76d9").should.not.be.ok;
});

it("should evaluate equality with .equals()", function() {
var id1 = ObjectID();
var id2 = ObjectID(id1.str);
(id1.equals(id2)).should.be.true;
});

it("should evaluate equality with via deepEqual", function() {
var id1 = ObjectID();
var id2 = ObjectID(id1.str);
id1.should.eql(id2);

var id3 = ObjectID();
id1.should.not.eql(id3, "id1 is not the same as id3");
});

it("should generate valid hex strings", function() {
var h = ObjectID.generate();
ObjectID.isValid(h).should.be.ok;
Expand Down

0 comments on commit b49356a

Please sign in to comment.