let sinon = require("sinon");
let main = require("../lib/main");
describe("main()", () => {
it("should display main menu once started", () => {
sinon.spy(console, "log");
main();
expect(console.log.args.join()).toBe(`1.
2.
3.
13:`);
});
it("should display :, , , , : , ...", () => {
// sinon.spy(console, "log");
const display = main();
// console.log(display)
expect(display).toBe(":, , , , : , ...:")
})
});
< H2 > function under test < / H2 >
module.exports = () => {
function choice1(){
let display = ":, , , , : , ...:"
return display;
}
function choice2(){
}
function choice3(){
}
function invalidInput1(){
}
function defaultPage(){
console.log( `1.
2.
3.
13:`)
}
defaultPage();
var readlineSync = require("readline-sync");
var answer = readlineSync.question();
if(answer == 1){
choice1();
}else if(answer == 2){
choice2();
}else if(answer == 3){
choice3();
}else{
return "Bad choice, please choose again!"
}
}
< H2 > run results < / H2 >