From 511480a90c5baadd0ceba0dcaf4da7a5390b76ab Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 3 Jul 2024 05:24:18 +0100 Subject: [PATCH] Test: Convert test/reporter-html "Display" to test/main/HtmlReporter.js --- test/main/HtmlReporter.js | 43 +++++++++++++++++++++++++++-- test/reporter-html/reporter-html.js | 23 --------------- 2 files changed, 41 insertions(+), 25 deletions(-) diff --git a/test/main/HtmlReporter.js b/test/main/HtmlReporter.js index 40eb95249..6afae17e8 100644 --- a/test/main/HtmlReporter.js +++ b/test/main/HtmlReporter.js @@ -26,7 +26,8 @@ this.emit('runStart', { testCounts: { total: 0 } }); this.emit('begin', { modules: [] }); }, - _do_mixed_run: function () { + // The first 1.5 test. + _do_mixed_run_half: function () { this.emit('runStart', { testCounts: { total: 4 } }); this.emit('begin', { modules: [] }); @@ -44,6 +45,9 @@ result: true, runtime: 1 }); + }, + _do_mixed_run_full: function () { + this._do_mixed_run_half(); this.emit('testDone', { testId: '00B', name: 'B', total: 1, passed: 1, failed: 0, runtime: 1 }); this.emit('testStart', { testId: '00C', name: 'C' }); @@ -79,6 +83,41 @@ } }); +QUnit.test('testresult-display [begin]', function (assert) { + var element = document.createElement('div'); + new QUnit.reporters.html(this.MockQUnit, { + element: element, + config: { + urlConfig: [] + } + }); + this.MockQUnit._do_start_empty(); + + var testresult = element.querySelector('#qunit-testresult'); + assert.equal(testresult.className, 'result', 'testresult class'); + assert.equal(testresult.textContent, 'Running...\u00A0Abort', 'testresult text'); + var display = element.querySelector('#qunit-testresult-display'); + assert.equal(display.className, '', 'display class'); + assert.equal(display.textContent, 'Running...\u00A0', 'display text'); +}); + +QUnit.test('testresult-display [testStart]', function (assert) { + var element = document.createElement('div'); + new QUnit.reporters.html(this.MockQUnit, { + element: element, + config: { + urlConfig: [] + } + }); + this.MockQUnit._do_mixed_run_half(); + + var testresult = element.querySelector('#qunit-testresult'); + assert.equal(testresult.className, 'result', 'testresult class'); + var display = element.querySelector('#qunit-testresult-display'); + assert.equal(display.className, 'running', 'display class'); + assert.equal(display.textContent, '1 / 4 tests completed.Running: B', 'display text'); +}); + QUnit.test('appendFilteredTest() [testId]', function (assert) { var element = document.createElement('div'); new QUnit.reporters.html(this.MockQUnit, { @@ -107,7 +146,7 @@ QUnit.test('hidepassed', function (assert) { urlConfig: ['hidepassed'] } }); - this.MockQUnit._do_mixed_run(); + this.MockQUnit._do_mixed_run_full(); // Of the 5 tests, hide 2 passed and 1 skipped, show 2 failed. var tests = element.querySelector('#qunit-tests'); diff --git a/test/reporter-html/reporter-html.js b/test/reporter-html/reporter-html.js index 4f48b5bf8..b4cf95aa0 100644 --- a/test/reporter-html/reporter-html.js +++ b/test/reporter-html/reporter-html.js @@ -29,29 +29,6 @@ QUnit.module('HTML Reporter', function () { assert.true(true, ""); }); - QUnit.module('Display'); - - QUnit.test("use 'running' class", function (assert) { - assert.equal(document.querySelectorAll('#qunit-testresult-display.running').length, 1); - }); - - QUnit.test('running text', function (assert) { - var display = document.getElementById('qunit-testresult'); - - assert.true(/running text/.test(display.innerHTML), 'test name'); - assert.true(/Display/.test(display.innerHTML), 'module name'); - }); - - QUnit.test('run progress', function (assert) { - var display = document.getElementById('qunit-testresult'); - - var expected = /\d+ \/ \d+ tests completed/; - assert.true( - expected.test(display.innerHTML), - 'progress found in displayed text' - ); - }); - QUnit.module('Duration', { getPreviousTest: function (assert) { return document.getElementById('qunit-test-output-' + assert.test.testId)