From e06d455a9bbaf8cdde3c879777facbe10fd1adc0 Mon Sep 17 00:00:00 2001 From: John Emau Date: Wed, 8 Jan 2020 15:11:02 -0800 Subject: [PATCH 1/2] tests(reportuifeatures): adding empty list and single item test cases --- .../html/renderer/report-ui-features-test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lighthouse-core/test/report/html/renderer/report-ui-features-test.js b/lighthouse-core/test/report/html/renderer/report-ui-features-test.js index 3a761fbc3060..05061df76672 100644 --- a/lighthouse-core/test/report/html/renderer/report-ui-features-test.js +++ b/lighthouse-core/test/report/html/renderer/report-ui-features-test.js @@ -353,6 +353,22 @@ describe('ReportUIFeatures', () => { createDiv = () => dom.document().createElement('div'); }); + it('should return undefined when nodes is empty', () => { + const nodes = []; + + const nextNode = dropDown._getNextSelectableNode(nodes); + + assert.strictEqual(nextNode, undefined); + }); + + it('should return only node', () => { + const nodes = [createDiv()]; + + const nextNode = dropDown._getNextSelectableNode(nodes); + + assert.strictEqual(nextNode, nodes[0]); + }); + it('should return first node when start is undefined', () => { const nodes = [createDiv(), createDiv()]; From f06cd3c58cd080ef82ca87d1ffb6897ade5e3220 Mon Sep 17 00:00:00 2001 From: John Emau Date: Thu, 9 Jan 2020 12:07:13 -0800 Subject: [PATCH 2/2] made test case more interesting per review feedback --- .../test/report/html/renderer/report-ui-features-test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lighthouse-core/test/report/html/renderer/report-ui-features-test.js b/lighthouse-core/test/report/html/renderer/report-ui-features-test.js index 05061df76672..92bd5753637a 100644 --- a/lighthouse-core/test/report/html/renderer/report-ui-features-test.js +++ b/lighthouse-core/test/report/html/renderer/report-ui-features-test.js @@ -361,12 +361,12 @@ describe('ReportUIFeatures', () => { assert.strictEqual(nextNode, undefined); }); - it('should return only node', () => { - const nodes = [createDiv()]; + it('should return the only node when start is defined', () => { + const node = createDiv(); - const nextNode = dropDown._getNextSelectableNode(nodes); + const nextNode = dropDown._getNextSelectableNode([node], node); - assert.strictEqual(nextNode, nodes[0]); + assert.strictEqual(nextNode, node); }); it('should return first node when start is undefined', () => {