Skip to content

Instantly share code, notes, and snippets.

@IntegerMan IntegerMan/Logic2.js
Created Oct 27, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.