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 commandline interface program to interact with it Use the following folder structure for the project: tacostandapp src tacostand.js index.js test tacostand.spec.js package.json
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
Create a TacoStandEmitter class module that extends the EventEmitter class from Node.js This class should have the following methods:
a serveCustomercustomer: string: Emits a serve event with the customer as the actual parameter.
b prepareTacotaco: string: Emits a prepare event with the taco as the actual parameter.
c handleRushrush: string: Emits a rush event with the rush as the actual parameter.
For the class module, write three diKerent unit tests in tacostandspec.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.
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.logPassed testPerformAction;
return true;
catcherr
console.errorFailed testPerformAction: $err;
return false;
Inside each test function, use a trycatch 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.
Create a CLI program indexjs that uses the TacoStandEmitter class. The input format should be command followed by a space and the argument. The commands are serveprepare 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
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
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
