Question: HOW CAN TEST THIS METHOD ON JEST OR JASMINE? var signatureList = [{ title : Yoda, message : The greatest teacher, failure is. ---Yoda },

HOW CAN TEST THIS METHOD ON JEST OR JASMINE?

var signatureList = [{

title : "Yoda",

message : "The greatest teacher, failure is. ---Yoda"

},

{

title : "Vader",

message : "All that I sense, is fear and dead men. ---Darth Vader"

},

{

title : "Han Solo",

message : "Its not wise to upset a Wookiee. ---Han Solo"

}]

Office.onReady(info => {

if (info.host === Office.HostType.Outlook) {

document.getElementById("removeThis").onclick = removeInList;

document.getElementById("addToLib").onclick = addToLib;

document.getElementById("showLib").onclick = showLibrary;

document.getElementById("applySignatureButton").onclick = applySignature;

document.getElementById("imFeelingLucky").onclick = applyRandomSignature;

}

});

function addToLib() {

// A function that creates a new object with title and message then adds it to the signature array

var newSignature = {title : document.getElementById("title_input").value,

message : document.getElementById("message_input").value

}

signatureList.push(newSignature);

var updatedDropdown = document.getElementById("signatures");

var option = document.createElement("option");

option.value = newSignature.title;

updatedDropdown.appendChild(option);

}

function showLibrary() {

// Need method for window to pop up with signatureList elements

var libraryList = ""

for (let signature of signatureList){

libraryList = libraryList + signature.title + " " + signature.message + "
"

}

document.getElementById("Library").innerHTML = libraryList;

}

function removeInList() {

// Removes the chosen element in the dropList

var title = document.querySelector('#signature').value;

var y = document.getElementById("signatures");

var i;

for (i = 0; i < signatureList.length; i++){

if (signatureList[i].title == title) {

signatureList.splice(i, 1)

y.children[i].remove()

}

}

showLibrary();

}

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 Databases Questions!