Skip to content

Commit

Permalink
specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikolas Howard committed Feb 27, 2024
1 parent 1b2a040 commit cf068a5
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 36 deletions.
16 changes: 8 additions & 8 deletions test/BehaviourTree.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe("A BehaviourTree instance", () => {
describe("has a 'getState' function that returns the state of the root node", () => {
it("(MDSL)", () => {
const definition = "root { action [getActionResult] }";
const agent = { getActionResult: () => {} };
const agent = { getActionResult: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

assert.strictEqual(tree.getState(), State.READY);
Expand All @@ -78,7 +78,7 @@ describe("A BehaviourTree instance", () => {
call: "getActionResult"
}
};
const agent = { getActionResult: () => {} };
const agent = { getActionResult: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

assert.strictEqual(tree.getState(), State.READY);
Expand All @@ -98,7 +98,7 @@ describe("A BehaviourTree instance", () => {
describe("has an 'isRunning' function that returns a flag defining whether the tree is in a running state", () => {
it("(MDSL)", () => {
const definition = "root { action [getActionResult] }";
const agent = { getActionResult: () => {} };
const agent = { getActionResult: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

assert.strictEqual(tree.isRunning(), false);
Expand All @@ -122,7 +122,7 @@ describe("A BehaviourTree instance", () => {
call: "getActionResult"
}
};
const agent = { getActionResult: () => {} };
const agent = { getActionResult: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

assert.strictEqual(tree.isRunning(), false);
Expand Down Expand Up @@ -203,7 +203,7 @@ describe("A BehaviourTree instance", () => {
const agent = {
getActionResult0: () => State.SUCCEEDED,
getActionResult1: () => State.SUCCEEDED,
getActionResult2: () => {},
getActionResult2: () => State.RUNNING,
getActionResult3: () => State.SUCCEEDED
};
const tree = new BehaviourTree(definition, agent);
Expand All @@ -229,7 +229,7 @@ describe("A BehaviourTree instance", () => {
assert.strictEqual(findNode(tree, "action", "getActionResult2").state, State.SUCCEEDED);
assert.strictEqual(findNode(tree, "action", "getActionResult3").state, State.SUCCEEDED);

agent.getActionResult2 = () => undefined;
agent.getActionResult2 = () => State.RUNNING;

tree.step();

Expand Down Expand Up @@ -267,7 +267,7 @@ describe("A BehaviourTree instance", () => {
const agent = {
getActionResult0: () => State.SUCCEEDED,
getActionResult1: () => State.SUCCEEDED,
getActionResult2: () => {},
getActionResult2: () => State.RUNNING,
getActionResult3: () => State.SUCCEEDED
};
const tree = new BehaviourTree(definition, agent);
Expand All @@ -293,7 +293,7 @@ describe("A BehaviourTree instance", () => {
assert.strictEqual(findNode(tree, "action", "getActionResult2").state, State.SUCCEEDED);
assert.strictEqual(findNode(tree, "action", "getActionResult3").state, State.SUCCEEDED);

agent.getActionResult2 = () => undefined;
agent.getActionResult2 = () => State.RUNNING;

tree.step();

Expand Down
4 changes: 2 additions & 2 deletions test/nodes/composite/Lotto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ describe("A Lotto node", () => {
describe("move to the RUNNING state if the selected child node is in the RUNNING state", () => {
it("(MDSL)", () => {
const definition = "root { lotto { action [someAction] } }";
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let lottoNode = findNode(tree, "lotto");
Expand Down Expand Up @@ -450,7 +450,7 @@ describe("A Lotto node", () => {
]
}
};
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let lottoNode = findNode(tree, "lotto");
Expand Down
24 changes: 12 additions & 12 deletions test/nodes/composite/Parallel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ describe("A Parallel node", () => {
it("(MDSL)", () => {
const definition = "root { parallel { action [actionRunning1] action [actionRunning2] } }";
const agent = {
actionRunning1: () => {},
actionRunning2: () => {}
actionRunning1: () => State.RUNNING,
actionRunning2: () => State.RUNNING
};
const tree = new BehaviourTree(definition, agent);

Expand Down Expand Up @@ -75,8 +75,8 @@ describe("A Parallel node", () => {
}
};
const agent = {
actionRunning1: () => {},
actionRunning2: () => {}
actionRunning1: () => State.RUNNING,
actionRunning2: () => State.RUNNING
};
const tree = new BehaviourTree(definition, agent);

Expand All @@ -98,8 +98,8 @@ describe("A Parallel node", () => {
it("(MDSL)", () => {
const definition = "root { parallel { action [action1] action [action2] } }";
const agent = {
action1: () => {},
action2: () => {}
action1: () => State.RUNNING,
action2: () => State.RUNNING
};
const tree = new BehaviourTree(definition, agent);

Expand Down Expand Up @@ -143,8 +143,8 @@ describe("A Parallel node", () => {
}
};
const agent = {
action1: () => {},
action2: () => {}
action1: () => State.RUNNING,
action2: () => State.RUNNING
};
const tree = new BehaviourTree(definition, agent);

Expand Down Expand Up @@ -175,8 +175,8 @@ describe("A Parallel node", () => {
it("(MDSL)", () => {
const definition = "root { parallel { action [action1] action [action2] } }";
const agent = {
action1: () => {},
action2: () => {}
action1: () => State.RUNNING,
action2: () => State.RUNNING
};
const tree = new BehaviourTree(definition, agent);

Expand Down Expand Up @@ -229,8 +229,8 @@ describe("A Parallel node", () => {
}
};
const agent = {
action1: () => {},
action2: () => {}
action1: () => State.RUNNING,
action2: () => State.RUNNING
};
const tree = new BehaviourTree(definition, agent);

Expand Down
4 changes: 2 additions & 2 deletions test/nodes/composite/Selector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ describe("A Selector node", () => {
"root { selector { action [actionFail] action [actionRunning] action [actionSucceed] } }";
const agent = {
actionSucceed: () => State.SUCCEEDED,
actionRunning: () => {},
actionRunning: () => State.RUNNING,
actionFail: () => State.FAILED
};
const tree = new BehaviourTree(definition, agent);
Expand Down Expand Up @@ -213,7 +213,7 @@ describe("A Selector node", () => {
};
const agent = {
actionSucceed: () => State.SUCCEEDED,
actionRunning: () => {},
actionRunning: () => State.RUNNING,
actionFail: () => State.FAILED
};
const tree = new BehaviourTree(definition, agent);
Expand Down
4 changes: 2 additions & 2 deletions test/nodes/composite/Sequence.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe("A Sequence node", () => {
"root { sequence { action [actionSucceed] action [actionRunning] action [actionFail] } }";
const agent = {
actionSucceed: () => State.SUCCEEDED,
actionRunning: () => {},
actionRunning: () => State.RUNNING,
actionFail: () => State.FAILED
};
const tree = new BehaviourTree(definition, agent);
Expand Down Expand Up @@ -202,7 +202,7 @@ describe("A Sequence node", () => {
};
const agent = {
actionSucceed: () => State.SUCCEEDED,
actionRunning: () => {},
actionRunning: () => State.RUNNING,
actionFail: () => State.FAILED
};
const tree = new BehaviourTree(definition, agent);
Expand Down
4 changes: 2 additions & 2 deletions test/nodes/decorator/Fail.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe("A Fail node", () => {
describe("move to the RUNNING state if the child node moves to the RUNNING state", () => {
it("(MDSL)", () => {
const definition = "root { fail { action [someAction] } }";
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let node = findNode(tree, "fail", "FAIL");
Expand All @@ -141,7 +141,7 @@ describe("A Fail node", () => {
}
}
};
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let node = findNode(tree, "fail", "FAIL");
Expand Down
4 changes: 2 additions & 2 deletions test/nodes/decorator/Flip.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe("A Flip node", () => {
describe("move to the RUNNING state if the child node does not move to the SUCCESS or FAILED state", () => {
it("(MDSL)", () => {
const definition = "root { flip { action [someAction] } }";
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let node = findNode(tree, "flip", "FLIP");
Expand All @@ -139,7 +139,7 @@ describe("A Flip node", () => {
}
}
};
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let node = findNode(tree, "flip", "FLIP");
Expand Down
4 changes: 2 additions & 2 deletions test/nodes/decorator/Root.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe("A Root node", () => {
describe("move to the RUNNING state if the child node does not move to the SUCCESS or FAILED state", () => {
it("(MDSL)", () => {
const definition = "root { action [someAction] }";
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

assert.strictEqual(findNode(tree, "root").state, State.READY);
Expand All @@ -117,7 +117,7 @@ describe("A Root node", () => {
call: "someAction"
}
};
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

assert.strictEqual(findNode(tree, "root").state, State.READY);
Expand Down
4 changes: 2 additions & 2 deletions test/nodes/decorator/Succeed.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ describe("A Succeed node", () => {
describe("move to the RUNNING state if the child node moves to the RUNNING state", () => {
it("(MDSL)", () => {
const definition = "root { succeed { action [someAction] } }";
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let node = findNode(tree, "succeed", "SUCCEED");
Expand All @@ -141,7 +141,7 @@ describe("A Succeed node", () => {
}
}
};
const agent = { someAction: () => {} };
const agent = { someAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let node = findNode(tree, "succeed", "SUCCEED");
Expand Down
4 changes: 2 additions & 2 deletions test/nodes/leaf/Action.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ describe("An Action node", () => {
describe("the function returns undefined", () => {
it("(MDSL)", () => {
const definition = "root { action [doAction] }";
const agent = { doAction: () => {} };
const agent = { doAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let node = findNode(tree, "action", "doAction");
Expand All @@ -413,7 +413,7 @@ describe("An Action node", () => {
call: "doAction"
}
};
const agent = { doAction: () => {} };
const agent = { doAction: () => State.RUNNING };
const tree = new BehaviourTree(definition, agent);

let node = findNode(tree, "action", "doAction");
Expand Down

0 comments on commit cf068a5

Please sign in to comment.