Skip to content

Commit

Permalink
get extend working
Browse files Browse the repository at this point in the history
  • Loading branch information
tyler-johnson committed Dec 11, 2014
1 parent 6793a60 commit 83a83c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var Document = require("./document");

// database extends backbone collection
Database.prototype = Object.create(Backbone.Collection.prototype);
Database.extend = Backbone.Collection.extend;

// database class extends document
_.extend(Database.prototype, {
Expand Down
12 changes: 12 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ describe("Documents", function() {
expect(doc.isNew()).to.not.be.ok;
});

it("can create subclass from Document class", function() {
var subclass = Lazybones.Document.extend({ foo: function() {} });
expect(subclass.prototype.foo).to.be.a.function;
expect(subclass.prototype.get).to.be.a.function;
});

});

describe("Database", function() {
Expand All @@ -41,6 +47,12 @@ describe("Database", function() {
db.destroy().then(function() { done(); }, done);
});

it("can create subclass from Database class", function() {
var subclass = Lazybones.extend({ foo: function() {} });
expect(subclass.prototype.foo).to.be.a.function;
expect(subclass.prototype.get).to.be.a.function;
});

});

describe("CRUD", function() {
Expand Down

0 comments on commit 83a83c9

Please sign in to comment.