Skip to content

Commit

Permalink
Small nomenclature changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
vakenbolt committed Jun 8, 2020
1 parent c4e5501 commit 59554ba
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
25 changes: 14 additions & 11 deletions test_report.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GoTestReportElements {}


/**
*
* Main entry point for GoTestReport.
* @param {GoTestReportElements} elements
* @returns {{testResultsClickHandler: testResultsClickHandler}}
* @constructor
Expand All @@ -60,9 +60,9 @@ window.GoTestReport = function (elements) {

const goTestReport = {
/**
*
* @param {HTMLElement} target
* @param {boolean} shiftKey
* Invoked when a user clicks on one of the test group div elements.
* @param {HTMLElement} target The element associated with the test group.
* @param {boolean} shiftKey If pressed, all of test detail associated to the test group is shown.
* @param {TestResults} data
* @param {SelectedItems} selectedItems
* @param {function(target: Element, data: TestResults)} testGroupListHandler
Expand All @@ -73,8 +73,8 @@ window.GoTestReport = function (elements) {
selectedItems,
testGroupListHandler) {
if (selectedItems.testResults != null) {
let f = /**@type {HTMLElement}*/ selectedItems.testResults
f.style.backgroundColor = selectedItems.selectedTestGroupColor
let testResultsElement = /**@type {HTMLElement}*/ selectedItems.testResults
testResultsElement.style.backgroundColor = selectedItems.selectedTestGroupColor
}
const testGroupId = /**@type {number}*/ target.id
const testResults = /**@type {TestResults}*/ data[testGroupId]['TestResults']
Expand Down Expand Up @@ -151,18 +151,21 @@ window.GoTestReport = function (elements) {
}
}

//+------------------------+
//| setup DOM events |
//+------------------------+
elements.testResultsElem
.addEventListener('click', event =>
goTestReport.testResultsClickHandler(/**@type {HTMLElement}*/ addEventData(event).data.target,
event.shiftKey,
elements.data,
selectedItems,
goTestReport.testGroupListHandler))
event.shiftKey,
elements.data,
selectedItems,
goTestReport.testGroupListHandler))

elements.testGroupListElem
.addEventListener('click', event =>
goTestReport.testGroupListHandler(/**@type {Element}*/ event.target,
elements.data))
elements.data))

return goTestReport
}
8 changes: 4 additions & 4 deletions test_report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ test('test GoTestReport constructor with click event on a test group', () => {


/**
*
* Returns an element using the provided testGroupId and testIndex.
* @param {number} testGroupId
* @param {number} testIndex
* @returns {HTMLDivElement}
*/
function foobar(testGroupId, testIndex) {
function createDataGroupElement(testGroupId, testIndex) {
const divElem = document.createElement('div')
const testGroupIdAttr = document.createAttribute('data-groupid')
testGroupIdAttr.value = testGroupId.toString()
Expand All @@ -118,7 +118,7 @@ function foobar(testGroupId, testIndex) {

test('test testGroupListHandler using [test group: 0]', () => {
const goTestReport = new window.GoTestReport(createTestElements());
let divElem = foobar(0, 0)
let divElem = createDataGroupElement(0, 0)
goTestReport.testGroupListHandler(divElem, mockData)
const testOutputDiv = divElem.querySelector('div.testOutput')
const consoleElem = testOutputDiv.querySelector('.console.failed')
Expand All @@ -132,7 +132,7 @@ test('test testGroupListHandler using [test group: 0]', () => {

test('test testGroupListHandler using [test group: 1]', () => {
const goTestReport = new window.GoTestReport(createTestElements());
let divElem = foobar(2, 0)
let divElem = createDataGroupElement(2, 0)
goTestReport.testGroupListHandler(divElem, mockData)
const testOutputDiv = divElem.querySelector('div.testOutput')
const consoleElem = testOutputDiv.querySelector('.console')
Expand Down

0 comments on commit 59554ba

Please sign in to comment.