diff --git a/spec/command.spec.js b/spec/command.spec.js index 9569b88a..ad709502 100644 --- a/spec/command.spec.js +++ b/spec/command.spec.js @@ -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); + }) + }); \ No newline at end of file diff --git a/spec/message.spec.js b/spec/message.spec.js index 04dad5f8..eed5b628 100644 --- a/spec/message.spec.js +++ b/spec/message.spec.js @@ -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); + }); }); diff --git a/spec/rover.spec.js b/spec/rover.spec.js index ee4bc65f..000bd166 100644 --- a/spec/rover.spec.js +++ b/spec/rover.spec.js @@ -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); +}); + });