From 190e5c2ffe1f8def45f1575ffbbdcd3feec0bc03 Mon Sep 17 00:00:00 2001 From: Benjamin Pannell Date: Mon, 27 Apr 2015 21:55:46 +0200 Subject: [PATCH] Updated and added some more tests --- test/Core.js | 11 ++++++++--- test/Core.js.map | 2 +- test/Core.ts | 12 +++++++++--- test/Instance.js | 29 +++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 7 deletions(-) diff --git a/test/Core.js b/test/Core.js index 5bb0885..e3ddbd2 100644 --- a/test/Core.js +++ b/test/Core.js @@ -82,9 +82,14 @@ describe("Core", function () { }); it("should have a default no-op cache provider", function () { chai.expect(core.cache).to.exist; - return core.cache.set("test", true).then(function () { - chai.expect(core.cache.get("test")).to.eventually.not.exist; - }); + core.cache.set("test", true); + chai.expect(core.cache.get("test")).to.eventually.not.exist; + }); + }); + describe("settings", function () { + it("should be exposed via the settings property", function () { + var core = new Iridium.Core({ database: 'test' }); + chai.expect(core.settings).to.exist.and.eql({ database: 'test' }); }); }); describe("connect", function () { diff --git a/test/Core.js.map b/test/Core.js.map index f4ca844..cf070d2 100644 --- a/test/Core.js.map +++ b/test/Core.js.map @@ -1 +1 @@ -{"version":3,"file":"Core.js","sourceRoot":"","sources":["Core.ts"],"names":["InheritedCore","InheritedCore.constructor","InheritedCoreWithCustomConstructor","InheritedCoreWithCustomConstructor.constructor"],"mappings":";;;;;;AACA,AADA,4CAA4C;AAC5C,IAAO,OAAO,WAAW,UAAU,CAAC,CAAC;AAErC,IAAM,aAAa;IAASA,UAAtBA,aAAaA,UAAqBA;IAAxCA,SAAMA,aAAaA;QAASC,8BAAYA;QACpCA,cAASA,GAAGA,EAAEA,CAACA;IACnBA,CAACA;IAADD,oBAACA;AAADA,CAACA,AAFD,EAA4B,OAAO,CAAC,IAAI,EAEvC;AAED,IAAM,kCAAkC;IAASE,UAA3CA,kCAAkCA,UAAqBA;IACzDA,SADEA,kCAAkCA;QAEhCC,kBAAMA,0BAA0BA,CAACA,CAACA;IACtCA,CAACA;I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AAS,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oCAAoC,EAAC;YACpC,IAAI,IAAI,GAAG,IAAI,kCAAkC,EAAE,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"Core.js","sourceRoot":"","sources":["Core.ts"],"names":["InheritedCore","InheritedCore.constructor","InheritedCoreWithCustomConstructor","InheritedCoreWithCustomConstructor.constructor"],"mappings":";;;;;;AACA,AADA,4CAA4C;AAC5C,IAAO,OAAO,WAAW,UAAU,CAAC,CAAC;AAErC,IAAM,aAAa;IAASA,UAAtBA,aAAaA,UAAqBA;IAAxCA,SAAMA,aAAaA;QAASC,8BAAYA;QACpCA,cAASA,GAAGA,EAAEA,CAACA;IACnBA,CAACA;IAADD,oBAACA;AAADA,CAACA,AAFD,EAA4B,OAAO,CAAC,IAAI,EAEvC;AAED,IAAM,kCAAkC;IAASE,UAA3CA,kCAAkCA,UAAqBA;IACzDA,SADEA,kCAAkCA;QAEhCC,kBAAMA,0BAA0BA,CAACA,CAACA;IACtCA,CAACA;IACLD,yCAACA;AAADA,CAACA,AAJD,EAAiD,OAAO,CAAC,IAAI,EAI5D;AAED,QAAQ,CAAC,MAAM,EAAC;IACZ,QAAQ,CAAC,aAAa,EAAC;QACnB,EAAE,CAAC,4BAA4B,EAAC;YAC5B,IAAI,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACxD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;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CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oCAAoC,EAAC;YACpC,IAAI,IAAI,GAAG,IAAI,kCAAkC,EAAE,CAAC;YACpD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/test/Core.ts b/test/Core.ts index e458db2..609b299 100644 --- a/test/Core.ts +++ b/test/Core.ts @@ -86,9 +86,15 @@ describe("Core",() => { it("should have a default no-op cache provider",() => { chai.expect(core.cache).to.exist; - return core.cache.set("test", true).then(() => { - chai.expect(core.cache.get("test")).to.eventually.not.exist; - }); + core.cache.set("test", true); + chai.expect(core.cache.get("test")).to.eventually.not.exist; + }); + }); + + describe("settings",() => { + it("should be exposed via the settings property",() => { + var core = new Iridium.Core({ database: 'test' }); + chai.expect(core.settings).to.exist.and.eql({ database: 'test' }); }); }); diff --git a/test/Instance.js b/test/Instance.js index 22a6f80..b90eb4e 100644 --- a/test/Instance.js +++ b/test/Instance.js @@ -6,6 +6,7 @@ var __extends = this.__extends || function (d, b) { }; /// var Iridium = require('../index'); +var MongoDB = require('mongodb'); var Test = (function (_super) { __extends(Test, _super); function Test() { @@ -41,6 +42,18 @@ describe("Instance", function () { before(function () { return core.connect(); }); after(function () { return core.close(); }); beforeEach(function () { return core.Test.remove(); }); + it("should default to isNew", function () { + var instance = new core.Test.Instance({ + answer: 42 + }); + chai.expect(instance).to.have.property("_isNew", true); + }); + it("should default to !isPartial", function () { + var instance = new core.Test.Instance({ + answer: 42 + }); + chai.expect(instance).to.have.property("_isPartial", false); + }); it("should expose the latest document values", function () { var instance = core.Test.helpers.wrapDocument({ _id: 'aaaaaa', @@ -94,6 +107,22 @@ describe("Instance", function () { chai.expect(instance).to.exist; chai.expect(instance.test).to.exist.and.be.a('function'); }); + describe("should handle _id in a special manner", function () { + beforeEach(function () { return core.Test.remove().then(function () { return core.Test.insert({ answer: 42 }); }); }); + afterEach(function () { return core.Test.remove(); }); + it("get should transform ObjectIDs into hex strings", function () { + return core.Test.get().then(function (instance) { + chai.expect(instance.document._id._bsontype).to.equal('ObjectID'); + chai.expect(instance._id).to.be.a('string').with.length(24); + }); + }); + it("set should transform hex strings into ObjectIDs by default", function () { + return core.Test.get().then(function (instance) { + instance._id = "aaaaaaaaaaaaaaaaaaaaaaaa"; + chai.expect(new MongoDB.ObjectID(instance.document._id).toHexString()).to.equal('aaaaaaaaaaaaaaaaaaaaaaaa'); + }); + }); + }); describe("save()", function () { beforeEach(function () { return core.Test.remove(); }); it("should avoid making calls to the database if no changes were made to the instance", function () {