Skip to content

Instantly share code, notes, and snippets.

@IntegerMan
Created October 27, 2019 01:47
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save IntegerMan/def3d48a627beb9c258e5370668d1d31 to your computer and use it in GitHub Desktop.
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