Began actually testing :(

This commit is contained in:
Thaum
2015-03-23 13:55:17 +00:00
parent 48f8cef928
commit dc8a286a9a
11 changed files with 196 additions and 20 deletions

2
.codio
View File

@@ -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

View File

@@ -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

View File

@@ -1 +1 @@
METEOR@1.0.4.1
METEOR@1.0.4.2

View File

@@ -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

View File

@@ -1 +0,0 @@
AutoForm.setDefaultTemplate('paper');

View File

@@ -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"]);
});

View File

@@ -0,0 +1 @@
../../tests

View File

@@ -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);
});
});
});
}

View File

@@ -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");
});
});
});
});
}

View File

@@ -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);
});
});
});
});
}

View File

@@ -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);
})
});
});
});
});
}