From dc8a286a9a24b0d87782032600fbd18e4cfcd4ca Mon Sep 17 00:00:00 2001 From: Thaum Date: Mon, 23 Mar 2015 13:55:17 +0000 Subject: [PATCH] Began actually testing :( --- .codio | 2 +- rpg-docs/.meteor/packages | 4 +- rpg-docs/.meteor/release | 2 +- rpg-docs/.meteor/versions | 20 ++-- .../client/globalHelpers/setupAutoform.js | 1 - rpg-docs/packages/tests-proxy/package.js | 14 +++ rpg-docs/packages/tests-proxy/tests | 1 + .../tests/mocha/client/sampleClientTest.js | 9 -- .../mocha/server/lib/characterUtility.js | 31 ++++++ .../mocha/server/model/character/character.js | 34 +++++++ .../mocha/server/model/character/effects.js | 98 +++++++++++++++++++ 11 files changed, 196 insertions(+), 20 deletions(-) delete mode 100644 rpg-docs/client/globalHelpers/setupAutoform.js create mode 100644 rpg-docs/packages/tests-proxy/package.js create mode 120000 rpg-docs/packages/tests-proxy/tests delete mode 100644 rpg-docs/tests/mocha/client/sampleClientTest.js create mode 100644 rpg-docs/tests/mocha/server/lib/characterUtility.js create mode 100644 rpg-docs/tests/mocha/server/model/character/character.js create mode 100644 rpg-docs/tests/mocha/server/model/character/effects.js diff --git a/.codio b/.codio index b9be9fad..3c35c30e 100644 --- a/.codio +++ b/.codio @@ -3,7 +3,7 @@ // Run button configuration "commands": { - "Run Meteor": "cd rpg-docs \n meteor run" + "Run Meteor": "ROOT_URL=http://period-sheriff-3000.codio.io\ncd rpg-docs \n meteor run" }, // Preview button configuration diff --git a/rpg-docs/.meteor/packages b/rpg-docs/.meteor/packages index 487418fb..e35c0bc6 100644 --- a/rpg-docs/.meteor/packages +++ b/rpg-docs/.meteor/packages @@ -14,8 +14,8 @@ reactive-var underscore aldeed:collection2 differential:vulcanize -aldeed:autoform -conielo:autoform-polymer-paper msavin:mongol matb33:collection-hooks zimme:collection-softremovable +momentjs:moment +mike:mocha diff --git a/rpg-docs/.meteor/release b/rpg-docs/.meteor/release index 23c04296..41f2e623 100644 --- a/rpg-docs/.meteor/release +++ b/rpg-docs/.meteor/release @@ -1 +1 @@ -METEOR@1.0.4.1 +METEOR@1.0.4.2 diff --git a/rpg-docs/.meteor/versions b/rpg-docs/.meteor/versions index 5aa24f35..568d1425 100644 --- a/rpg-docs/.meteor/versions +++ b/rpg-docs/.meteor/versions @@ -2,12 +2,12 @@ accounts-base@1.2.0 accounts-password@1.1.0 accounts-ui@1.1.5 accounts-ui-unstyled@1.1.7 -aldeed:autoform@4.2.2 aldeed:collection2@2.3.2 aldeed:simple-schema@1.3.0 -aldeed:template-extension@3.4.1 +aldeed:template-extension@3.4.3 +amplify@1.0.0 autoupdate@1.2.0 -babrahams:editable-json@0.3.9 +babrahams:editable-json@0.3.11 base64@1.0.3 binary-heap@1.0.3 blaze@2.1.0 @@ -16,7 +16,6 @@ boilerplate-generator@1.0.3 callback-hook@1.0.3 check@1.0.5 coffeescript@1.0.6 -conielo:autoform-polymer-paper@0.1.1 dburles:collection-helpers@1.0.2 dburles:mongo-collection-instances@0.3.3 ddp@1.1.0 @@ -51,15 +50,19 @@ logging@1.0.7 matb33:collection-hooks@0.7.11 meteor@1.1.5 meteor-platform@1.2.2 +meteortoys:toykit@0.2.1 +mike:mocha@0.5.2 minifiers@1.1.4 minimongo@1.0.7 mobile-status-bar@1.0.3 -momentjs:moment@2.8.4 +momentjs:moment@2.9.0 mongo@1.1.0 -msavin:mongol@1.0.2 +msavin:mongol@1.0.5 npm-bcrypt@0.7.8_1 observe-sequence@1.0.5 ordered-dict@1.0.3 +practicalmeteor:chai@1.9.2_3 +practicalmeteor:loglevel@1.1.0_3 random@1.0.3 reactive-dict@1.1.0 reactive-var@1.0.5 @@ -77,6 +80,11 @@ tracker@1.0.6 ui@1.0.6 underscore@1.0.3 url@1.0.4 +velocity:core@0.4.5 +velocity:html-reporter@0.3.2 +velocity:node-soft-mirror@0.3.1 +velocity:shim@0.1.0 +velocity:test-proxy@0.0.4 webapp@1.2.0 webapp-hashing@1.0.3 zimme:collection-behaviours@1.0.3 diff --git a/rpg-docs/client/globalHelpers/setupAutoform.js b/rpg-docs/client/globalHelpers/setupAutoform.js deleted file mode 100644 index 2a956027..00000000 --- a/rpg-docs/client/globalHelpers/setupAutoform.js +++ /dev/null @@ -1 +0,0 @@ -AutoForm.setDefaultTemplate('paper'); \ No newline at end of file diff --git a/rpg-docs/packages/tests-proxy/package.js b/rpg-docs/packages/tests-proxy/package.js new file mode 100644 index 00000000..ab81b79d --- /dev/null +++ b/rpg-docs/packages/tests-proxy/package.js @@ -0,0 +1,14 @@ +Package.describe({ + name: "velocity:test-proxy", + summary: "Dynamically created package to expose test files to mirrors", + version: "0.0.4", + debugOnly: true +}); + +Package.onUse(function (api) { + api.use("coffeescript", ["client", "server"]); + api.add_files("tests/mocha/server/lib/characterUtility.js",["server"]); + api.add_files("tests/mocha/server/model/character/character.js",["server"]); + api.add_files("tests/mocha/server/model/character/effects.js",["server"]); + api.add_files("tests/mocha/server/sampleServerTest.js",["server"]); +}); \ No newline at end of file diff --git a/rpg-docs/packages/tests-proxy/tests b/rpg-docs/packages/tests-proxy/tests new file mode 120000 index 00000000..c2ebfe53 --- /dev/null +++ b/rpg-docs/packages/tests-proxy/tests @@ -0,0 +1 @@ +../../tests \ No newline at end of file diff --git a/rpg-docs/tests/mocha/client/sampleClientTest.js b/rpg-docs/tests/mocha/client/sampleClientTest.js deleted file mode 100644 index 8122e829..00000000 --- a/rpg-docs/tests/mocha/client/sampleClientTest.js +++ /dev/null @@ -1,9 +0,0 @@ -if (!(typeof MochaWeb === 'undefined')){ - MochaWeb.testOnly(function(){ - describe("a group of tests", function(){ - it("should respect equality", function(){ - chai.assert.equal(5,5); - }); - }); - }); -} diff --git a/rpg-docs/tests/mocha/server/lib/characterUtility.js b/rpg-docs/tests/mocha/server/lib/characterUtility.js new file mode 100644 index 00000000..df772800 --- /dev/null +++ b/rpg-docs/tests/mocha/server/lib/characterUtility.js @@ -0,0 +1,31 @@ +if (!(typeof MochaWeb === 'undefined')){ + MochaWeb.testOnly(function(){ + describe("CharacterUtility", function(){ + describe(("getMod"), function(){ + it("should return a 0 for 10 and 11", function(){ + chai.assert.equal(getMod(10), 0); + chai.assert.equal(getMod(11), 0); + }); + it("should return a 4 for 18 and 19", function(){ + chai.assert.equal(getMod(18), 4); + chai.assert.equal(getMod(19), 4); + }); + it("should return a -3 for 4 and 5", function(){ + chai.assert.equal(getMod(4), -3); + chai.assert.equal(getMod(5), -3); + }); + }); + describe(("signedString"), function(){ + it("should return a +1 for 1", function(){ + chai.assert.equal(signedString(1), "+1"); + }); + it("should return a +0 for 0", function(){ + chai.assert.equal(signedString(0), "+0"); + }); + it("should return a -1 for -1", function(){ + chai.assert.equal(signedString(-1), "-1"); + }); + }); + }); + }); +} diff --git a/rpg-docs/tests/mocha/server/model/character/character.js b/rpg-docs/tests/mocha/server/model/character/character.js new file mode 100644 index 00000000..10c96732 --- /dev/null +++ b/rpg-docs/tests/mocha/server/model/character/character.js @@ -0,0 +1,34 @@ +if (!(typeof MochaWeb === 'undefined')){ + MochaWeb.testOnly(function(){ + var charId; + describe("Character", function(){ + describe("insert", function(){ + it("should create a character", function(done){ + Characters.insert({owner: "FWeGYyDY5jc4HuTh8"}, function(err, id){ + charId = id; + done(err); + }); + }); + }); + describe("attribute.adjustment", function(){ + Characters.insert({owner: "FWeGYyDY5jc4HuTh8"}, function(err, id){ + charId = id; + done(err); + }); + it("should track attribute adjustments", function(){ + Characters.update(charId, {$set: {"strength.adjustment": -12}},{},function(err, num){ + console.log(num); + done(err); + }); + }); + it("should report the adjusted attribute correctly", function(){ + var val = Characters.findOne(charId).attributeValue("strength"); + chai.assert.equal(val, -12); + val = 0; + val = Characters.findOne(charId).fieldValue("strength"); + chai.assert.equal(val, -12); + }); + }); + }); + }); +} diff --git a/rpg-docs/tests/mocha/server/model/character/effects.js b/rpg-docs/tests/mocha/server/model/character/effects.js new file mode 100644 index 00000000..8dce017a --- /dev/null +++ b/rpg-docs/tests/mocha/server/model/character/effects.js @@ -0,0 +1,98 @@ +var getEffect = function(charId, op, value){ + return { + charId: charId, + type: "inate", + stat: "constitution", + operation: op, + value: value, + parent: { + id: charId, + collection: "Characters" + } + } +}; + +if (!(typeof MochaWeb === 'undefined')){ + MochaWeb.testOnly(function(){ + describe("Character", function(){ + Effects.remove({}); + Characters.remove({}); + var charId = Characters.insert({owner: "FWeGYyDY5jc4HuTh8"}); + var char = Characters.findOne(charId); + var con = function(){return char.attributeValue("constitution")}; + + describe("effects", function(){ + describe("attributeValue", function(){ + + it("should be set to highest base", function(done){ + Effects.insert(getEffect(charId, "base", 10), function(err, id){ + if(err) done(err); + }); + Effects.insert(getEffect(charId, "base", 6), function(err, id){ + if(err) done(err); + }); + chai.assert.equal(10, con()); + done(); + }); + + it("should add", function(done){ + Effects.insert(getEffect(charId, "add", 2), function(err, id){ + if(err) done(err); + }); + chai.assert.equal(12, con()); + done(); + }); + + it("should multiply", function(done){ + Effects.insert(getEffect(charId, "mul", 2), function(err, id){ + if(err) done(err); + }); + chai.assert.equal(24, con()); + done(); + }); + + it("should be at least highest min", function(done){ + Effects.insert(getEffect(charId, "min", 22), function(err, id){ + if(err) done(err); + }); + chai.assert.equal(con(), 24); + Effects.insert(getEffect(charId, "min", 28), function(err, id){ + if(err) done(err); + }); + chai.assert.equal(28, con()); + done(); + }); + + it("should be at most lowest max", function(done){ + Effects.insert(getEffect(charId, "max", 30), function(err, id){ + if(err) done(err); + }); + chai.assert.equal(28, con()); + Effects.insert(getEffect(charId, "max", 5), function(err, id){ + if(err) done(err); + }); + chai.assert.equal(5, con()); + done(); + }); + + it("should respect adjustment", function(done){ + Characters.update(charId, {$set: {"constitution.adjustment": -2}}, function(err, num){ + if(err) done(err); + }) + chai.assert.equal(3, con()); + var conBase = char.attributeBase("constitution"); + chai.assert.equal(5, conBase) + done(); + }); + + it("should be removed when the character is deleted", function(){ + Characters.remove(charId); + var count = Effects.find({charId: charId}).count(); + chai.assert.equal(count, 0); + }) + + }); + }); + }); + }); +}