Question: In this assignment you will use TDD principles to create a taco stand event emitter and a command - line interface program to interact with

In this assignment you will use TDD principles to create a taco stand event emitter and a command-line interface program to interact with it. Use the following folder structure for the project: taco-stand-app src taco-stand.js index.js test taco-stand.spec.js 84 package.json
1. In your package.json file, add a test script (for your unit tests) and a start script (for the CLI program). Remember to use strict mode in all JavaScript files (including test files).
2. Create a TacoStandEmitter class module that extends the EventEmitter class from Node.js. This class should have the following methods:
a. serveCustomer(customer: string): Emits a serve event with the customer as the actual parameter.
b. prepareTaco(taco: string): Emits a prepare event with the taco as the actual parameter.
c. handleRush(rush: string): Emits a rush event with the rush as the actual parameter.
3. For the class module, write three (3) diKerent unit tests in taco-stand-spec.js using the Node.js assert library. Each test should register an event listener for the emitted event, call the class method, and print either a pass or fail message to the console.
4. Each test should be wrapped in a function named testFunctionDescription, where functionDescription is a brief description of what the test does. For example, a test for the serveCustomer method could be named testServeCustomer. Below is an example to get you started:
function testPerformAction(){
try {
// register an event listener for the action event
// call the perform action method
console.log(Passed testPerformAction);
return true;
} catch(err){
console.error(`Failed testPerformAction: ${err}`);
return false;
}
}
5. Inside each test function, use a try-catch block to run the test and catch any errors. If the test passes, print a message indicating it passed and return true. If the test fails, print a message indicating the test failed and return false. 85
6. Create a CLI program (index.js) that uses the TacoStandEmitter class. The input format should be command followed by a space and the argument. The commands are serve,prepare, and rush.
a. Command serve John; prints Taco Stand serves: John
b. Command prepare beef; prints Taco Stand prepares: beef taco
c. Command rush lunch; prints Taco Stand handles rush: lunch
7. Use TDD principles to guide your development eKorts. Write your tests first, then write the code to make the tests pass, then refactor (Red Green Refactor).
In this assignment you will use TDD principles to

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!