From 0168039a978541b10488dc96af6abece5ec645ee Mon Sep 17 00:00:00 2001 From: Diogo Resende Date: Wed, 10 Jul 2013 23:38:07 +0100 Subject: [PATCH] Moves db.load() test to new framework --- .../{ => deprecated}/models/model.js | 0 .../{ => deprecated}/models/sub/index.js | 0 .../integration/{ => deprecated}/test-load.js | 0 test/integration2/db.js | 25 +++++++++++++++++++ test/support/spec_load.js | 7 ++++++ test/support/spec_load_second.js | 9 +++++++ 6 files changed, 41 insertions(+) rename test/integration/{ => deprecated}/models/model.js (100%) rename test/integration/{ => deprecated}/models/sub/index.js (100%) rename test/integration/{ => deprecated}/test-load.js (100%) create mode 100644 test/support/spec_load.js create mode 100644 test/support/spec_load_second.js diff --git a/test/integration/models/model.js b/test/integration/deprecated/models/model.js similarity index 100% rename from test/integration/models/model.js rename to test/integration/deprecated/models/model.js diff --git a/test/integration/models/sub/index.js b/test/integration/deprecated/models/sub/index.js similarity index 100% rename from test/integration/models/sub/index.js rename to test/integration/deprecated/models/sub/index.js diff --git a/test/integration/test-load.js b/test/integration/deprecated/test-load.js similarity index 100% rename from test/integration/test-load.js rename to test/integration/deprecated/test-load.js diff --git a/test/integration2/db.js b/test/integration2/db.js index 3e313d69..a9250fd7 100644 --- a/test/integration2/db.js +++ b/test/integration2/db.js @@ -29,3 +29,28 @@ describe("db.define()", function() { return done(); }); }); + +describe("db.load()", function () { + var db = null; + + before(function (done) { + helper.connect(function (connection) { + db = connection; + + return done(); + }); + }); + + after(function () { + return db.close(); + }); + + it("should require a file based on relative path", function (done) { + db.load("../support/spec_load", function () { + db.models.should.have.property("person"); + db.models.should.have.property("pet"); + + return done(); + }); + }); +}); diff --git a/test/support/spec_load.js b/test/support/spec_load.js new file mode 100644 index 00000000..7fd5c109 --- /dev/null +++ b/test/support/spec_load.js @@ -0,0 +1,7 @@ +module.exports = function (db, cb) { + db.define("person", { + name : String + }); + + return db.load("./spec_load_second", cb); +}; diff --git a/test/support/spec_load_second.js b/test/support/spec_load_second.js new file mode 100644 index 00000000..6f54edc8 --- /dev/null +++ b/test/support/spec_load_second.js @@ -0,0 +1,9 @@ +module.exports = function (db, cb) { + db.define("pet", { + name : String + }); + + setTimeout(function () { + return cb(); + }, 200); +};