Skip to content

Commit 1152857

Browse files
1 parent f5ee025 commit 1152857

1 file changed

Lines changed: 32 additions & 21 deletions

File tree

spec/rover.spec.js

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,43 @@ describe("Rover class", function() {
2828
let commands = [new Command('MODE_CHANGE', 'LOW_POWER'), new Command('STATUS_CHECK')];
2929
let message = new Message("test name", commands);
3030
let receiveMessage = rover.receiveMessage(message).results.length;
31-
3231
expect(receiveMessage).toEqual(2);
3332
});
3433
//10
35-
// it("responds correctly to the status check command", function() {
36-
// let rover = new Rover(2500);
37-
// let commands = [new Command('MODE_CHANGE', 'LOW_POWER'), new Command('STATUS_CHECK')];
38-
// let message = new Message('STATUS_CHECK', commands);
39-
// let receiveMessage = rover.receiveMessage(message);
40-
// expect(receiveMessage[0].roverStatus).toBe({
41-
// mode: 'NORMAL',
42-
// generatorWatts: 110,
43-
// position: 2500
44-
// });
45-
46-
// });
34+
it("responds correctly to the status check command", function() {
35+
let rover = new Rover(2500);
36+
let commands = [new Command('MODE_CHANGE', 'LOW_POWER'), new Command('STATUS_CHECK')];
37+
let message = new Message('STATUS_CHECK', commands);
38+
let receiveMessage = rover.receiveMessage(message).results;
39+
expect(receiveMessage[0]).toEqual({"completed": true});
40+
expect(receiveMessage[1]).toEqual({"completed": true, "roverStatus": {generatorWatts: 110, mode: "LOW_POWER", position: 2500}});
41+
42+
});
4743
// //11
48-
// it("responds correctly to the mode change command", function() {
44+
it("responds correctly to the mode change command", function() {
45+
let rover = new Rover(2500);
46+
let commands = [new Command('MODE_CHANGE', 'LOW_POWER')];
47+
let message = new Message('MODE_CHANGE', commands);
48+
let receiveMessage = rover.receiveMessage(message).results;
49+
expect(receiveMessage[0]).toEqual({"completed": true});
4950

50-
// });
51+
});
5152
// //12
52-
// it("responds with a false completed value when attempting to move in LOW_POWER mode", function() {
53-
54-
// });
55-
// //13
56-
// it("responds with the position for the move command", function() {
53+
it("responds with a false completed value when attempting to move in LOW_POWER mode", function() {
54+
let rover = new Rover(2500);
55+
let commands = [new Command('MODE_CHANGE', 'LOW_POWER'), new Command('MOVE', 500)];
56+
let message = new Message('MOVE', commands);
57+
let receiveMessage = rover.receiveMessage(message).results;
58+
expect(receiveMessage[1]).toEqual({"completed": false});
5759

58-
// });
60+
});
61+
// // //13
62+
it("responds with the position for the move command", function() {
63+
let rover = new Rover(2500);
64+
let commands = [new Command('MODE_CHANGE', 'NORMAL'), new Command('MOVE', 500)];
65+
let message = new Message('MOVE', commands);
66+
let receiveMessage = rover.receiveMessage(message);
67+
expect(receiveMessage.results[0]).toEqual({"completed": true});
68+
expect(rover.position).toEqual(500);
69+
});
5970
});

0 commit comments

Comments
 (0)