Skip to content

Commit

Permalink
completed 7 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
luciemariec committed Feb 21, 2024
1 parent 1fe6520 commit edd1cef
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
11 changes: 11 additions & 0 deletions spec/command.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,15 @@ describe("Command class", function() {
expect( function() { new Command();}).toThrow(new Error('Command type required.'));
});

it("constructor sets command type", function() {
let command = new Command('someType');
expect(command.commandType).toBe('someType');
});

it("constructor sets a value passed in as the 2nd argument", function() {
let value = 'someValue';
let command = new Command('someType', value);
expect(command.value).toBe(value);
})

});
14 changes: 14 additions & 0 deletions spec/message.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,18 @@ const Command = require('../command.js');

describe("Message class", function() {

it("throws error if a name is NOT passed into the constructor as the first parameter", function() {
expect( function() { new Message();}).toThrow(new Error('Name required.'));
});

it("constructor sets name", function() {
let name = new Message('someName');
expect(name.name).toBe('someName');
});

it("contains a commands array passed into the constructor as the 2nd argument", function() {
let commands = [new Command('command1'), new Command('command2')];
let message = new Message('someName', commands);
expect(message.commands).toEqual(commands);
});
});
10 changes: 8 additions & 2 deletions spec/rover.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ const Command = require('../command.js');


describe("Rover class", function() {

// 7 tests here!
//Test 7
it("constructor sets position and default values for mode and generatorWatts", function() {
let roverTest = new Rover (87382098);
expect(roverTest.position).toEqual(87382098);
expect(roverTest.mode).toEqual('NORMAL');
expect(roverTest.generatorWatts).toEqual(110);
});


});

0 comments on commit edd1cef

Please sign in to comment.