Created
October 27, 2019 01:47
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function updateTestCases() { | |
// Clear the existing items | |
var list = document.getElementById('listTestCases'); | |
list.innerHTML = ''; | |
for (testcase of this.testCases) { | |
addTestCaseToUI(testcase); | |
} | |
// Show or hide the empty items list | |
if (this.testCases.length > 0) { | |
hideAddItemsPrompt(); | |
} else { | |
showAddItemsPrompt(); | |
} | |
} | |
function addTestCaseToUI(testCase) { | |
var list = document.getElementById('listTestCases'); | |
var child = document.createElement('div'); | |
child.className = 'list-group-item'; | |
var header = document.createElement('h3'); | |
header.innerText = testCase.name; | |
header.className = testCase.isPassing ? 'text-success' : 'text-danger'; | |
child.appendChild(header); | |
var buttons = document.createElement('div'); | |
buttons.className = 'btn-group'; | |
buttons.innerHTML = `<button class='btn btn-success' onclick='passTestCase(${testCase.id});'>Pass</button> | |
<button class='btn btn-danger' onclick='failTestCase(${testCase.id});'>Fail</button> | |
<button class='btn btn-outline-danger ml-2' onclick='deleteTestCase(${testCase.id});'>Delete</button>`; | |
child.appendChild(buttons); | |
list.appendChild(child); | |
} | |
function hideAddItemsPrompt() { | |
const label = document.getElementById('lblNoTestCases'); | |
label.className = 'invisible'; | |
} | |
function showAddItemPrompt() { | |
const label = document.getElementById('lblNoTestCases'); | |
label.className = 'text-muted'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment