Question: in javascript using the Jasmine NPM module, how would one code these tests. Command tests Test 1 Create a second Command test using, constructor sets

in javascript using the Jasmine NPM module, how would one code these tests.

Command tests

Test 1

Create a secondCommandtest using, "constructor sets command type" as the description. This test checks that theconstructorin theCommandclass correctly sets thecommandTypeproperty in the new object.

  1. Without editing,command.jscontains the correct code. Click "Run" to verify that the first and second tests both pass.
  2. You do not need to useassert.throws()in this test.
  3. You may not need to know the specific types of commands to write this test.

Test 2

Code a third test using, "constructor sets a value passed in as the 2nd argument" as the description. This test checks that theconstructorcorrectly sets thevalueproperty in the new object.

  1. You may not need to know a propervaluein order to write this test.

Message tests

Test 1

For this test description, use the text, "throws error if a name is NOT passed into the constructor as the first parameter".

Test 2

Use "constructor sets name" as the description. The test confirms that theconstructorin theMessageclass correctly sets thenameproperty in a new message object.

Test 3

Use "contains a commands array passed into the constructor as 2nd argument". This test confirms that thecommandsproperty of a new message object contains the data passed in from theMessage(name,commands)call.

  1. Hint: Inside this test, you will have to create acommandsarray, fill it with someCommandobjects, and pass it into theMessageconstructor.

Rover tests

Test 1

"constructor sets position and default values for mode and generatorWatts". Refer to theRover Classdescription above for these default values.

Test 2

"response returned by receiveMessage contains name of message"

Test 3

"response returned by receiveMessage includes two results if two commands are sent in the message"

Test 4

"responds correctly to status check command"

  1. For theSTATUS_CHECKcommand,receiveMessage(message).resultsincludes aroverStatusobject describing the current state of the rover object ---mode,generatorWatts, andposition. The test should check each of these for accuracy.
  2. See theRover Command Typestable for more details.

Test 5

"responds correctly to mode change command".

  1. The test should check thecompletedproperty and rover mode for accuracy.
  2. The rover has two modes that can be passed a values to a mode change command, 'LOW_POWER' and 'NORMAL'.

Test 6

"responds with false completed value when attempting to move in LOW_POWER mode".

  1. The test should check thecompletedproperty for accuracy and confirm that the rover position did not change.
  2. Use theRover Modes tablefor guidance on how to handle move commands in different modes.

Test 7

"responds with position for move command".

  1. AMOVEcommand will update the rover's position with the position value in the command.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!