Skip to content

Commit

Permalink
Removed redundant tests and split out larger specs
Browse files Browse the repository at this point in the history
  • Loading branch information
doug-martin committed Feb 28, 2013
1 parent 4812398 commit 35bfa99
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 82 deletions.
48 changes: 20 additions & 28 deletions test/flow.compiled.test.js
Expand Up @@ -150,21 +150,32 @@ it.describe("Flow compiled",function (it) {
Result = flow.getDefined("result");
});

it.should("calculate fibonacci numbers", function () {
it.should("calculate fibonacci 3", function () {
var result = new Result();
return flow.getSession(new Fibonacci(3), result).match()
.then(function () {
assert.equal(result.value, 2);
return flow.getSession(new Fibonacci(4), result).match();
})
.then(function () {
assert.equal(result.value, 3);
return flow.getSession(new Fibonacci(5), result).match();
})
});
});

it.should("calculate fibonacci 4", function () {
var result = new Result();
return flow.getSession(new Fibonacci(4), result).match().then(function () {
assert.equal(result.value, 3);
});
});

it.should("calculate fibonacci 5", function () {
var result = new Result();
return flow.getSession(new Fibonacci(5), result).match()
.then(function () {
assert.equal(result.value, 5);
return flow.getSession(new Fibonacci(6), result).match();
})
});
});

it.should("calculate fibonacci 6", function () {
var result = new Result();
return flow.getSession(new Fibonacci(6), result).match()
.then(function () {
assert.equal(result.value, 8);
});
Expand Down Expand Up @@ -203,25 +214,6 @@ it.describe("Flow compiled",function (it) {
});
});

it.should("treat properly on consecutive runs", function () {
var session = flow.getSession();
var results = [];
session.assert(new Patient({name: "Tom", fever: "none", spots: true, rash: false, soreThroat: false, innoculated: false}));
session.assert(new Patient({name: "Bob", fever: "high", spots: false, rash: false, soreThroat: true, innoculated: false}));
session.assert(new Patient({name: "Joe", fever: "high", spots: true, rash: false, soreThroat: false, innoculated: true}));
session.assert(new Patient({name: "Fred", fever: "none", spots: false, rash: true, soreThroat: false, innoculated: false}));
session.assert(results);
//flow.print();
return session.match().then(function () {
session.dispose();
assert.deepEqual(results, [
{"name": "Fred", "treatment": "allergyShot"},
{"name": "Joe", "treatment": "penicillin"},
{"name": "Bob", "treatment": "bedRest"},
{"name": "Tom", "treatment": "allergyShot"}
]);
});
});
});
}).as(module);

Expand Down
50 changes: 21 additions & 29 deletions test/flow.dsl.test.js
Expand Up @@ -143,26 +143,38 @@ it.describe("Flow dsl",function (it) {
var Fibonacci = flow.getDefined("fibonacci");
var Result = flow.getDefined("result");

it.should("calculate fibonacci numbers", function () {
it.should("calculate fibonacci 3", function () {
var result = new Result();
return flow.getSession(new Fibonacci(3), result).match()
.then(function () {
assert.equal(result.value, 2);
return flow.getSession(new Fibonacci(4), result).match();
})
.then(function () {
assert.equal(result.value, 3);
return flow.getSession(new Fibonacci(5), result).match();
})
});
});

it.should("calculate fibonacci 4", function () {
var result = new Result();
return flow.getSession(new Fibonacci(4), result).match().then(function () {
assert.equal(result.value, 3);
});
});

it.should("calculate fibonacci 5", function () {
var result = new Result();
return flow.getSession(new Fibonacci(5), result).match()
.then(function () {
assert.equal(result.value, 5);
return flow.getSession(new Fibonacci(6), result).match();
})
});
});

it.should("calculate fibonacci 6", function () {
var result = new Result();
return flow.getSession(new Fibonacci(6), result).match()
.then(function () {
assert.equal(result.value, 8);
});
});


});

it.describe("diagnosis using dsl", function (it) {
Expand Down Expand Up @@ -190,26 +202,6 @@ it.describe("Flow dsl",function (it) {
]);
});
});

it.should("treat properly on consecutive runs", function () {
var session = flow.getSession();
var results = [];
session.assert(new Patient({name: "Tom", fever: "none", spots: true, rash: false, soreThroat: false, innoculated: false}));
session.assert(new Patient({name: "Bob", fever: "high", spots: false, rash: false, soreThroat: true, innoculated: false}));
session.assert(new Patient({name: "Joe", fever: "high", spots: true, rash: false, soreThroat: false, innoculated: true}));
session.assert(new Patient({name: "Fred", fever: "none", spots: false, rash: true, soreThroat: false, innoculated: false}));
session.assert(results);
//flow.print();
return session.match().then(function () {
session.dispose();
assert.deepEqual(results, [
{"name": "Fred", "treatment": "allergyShot"},
{"name": "Joe", "treatment": "penicillin"},
{"name": "Bob", "treatment": "bedRest"},
{"name": "Tom", "treatment": "allergyShot"}
]);
});
});
});
}).as(module);

Expand Down
43 changes: 18 additions & 25 deletions test/flow.test.js
Expand Up @@ -422,24 +422,33 @@ it.describe("Flow",function (it) {
});


it.should("calculate fibonacci numbers", function () {
it.should("calculate fibonacci 3", function () {
return flow.getSession(new Fibonacci(3)).match()
.then(function () {
assert.equal(result, 2);
return flow.getSession(new Fibonacci(4)).match();
})
.then(function () {
assert.equal(result, 3);
return flow.getSession(new Fibonacci(5)).match()
})
});
});

it.should("calculate fibonacci 4", function () {
return flow.getSession(new Fibonacci(4)).match().then(function () {
assert.equal(result, 3);
});
});

it.should("calculate fibonacci 5", function () {
return flow.getSession(new Fibonacci(5)).match()
.then(function () {
assert.equal(result, 5);
return flow.getSession(new Fibonacci(6)).match();
})
});
});

it.should("calculate fibonacci 6", function () {
return flow.getSession(new Fibonacci(6)).match()
.then(function () {
assert.equal(result, 8);
});
});

});


Expand Down Expand Up @@ -548,22 +557,6 @@ it.describe("Flow",function (it) {
});
});

it.should("treat properly on consecutive runs", function () {
var session = flow.getSession();
session.assert(new Patient("Tom", "none", true, false, false, false));
session.assert(new Patient("Bob", "high", false, false, true, false));
session.assert(new Patient("Joe", "high", true, false, false, true));
session.assert(new Patient("Fred", "none", false, true, false, false));
return session.match().then(function () {
session.dispose();
assert.deepEqual(results, [
{"name": "Fred", "treatment": "allegryShot"},
{"name": "Joe", "treatment": "penicillin"},
{"name": "Bob", "treatment": "bedRest"},
{"name": "Tom", "treatment": "allegryShot"}
]);
});
});
});

}).as(module);
Expand Down

0 comments on commit 35bfa99

Please sign in to comment.