Skip to content

Commit

Permalink
Rename lineRanges to availableLineRanges
Browse files Browse the repository at this point in the history
  • Loading branch information
mattzeunert committed Feb 11, 2019
1 parent e2eab1d commit 8aa311d
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions lighthouse-core/test/report/html/renderer/snippet-renderer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ const TEMPLATE_FILE = fs.readFileSync(
'utf8'
);

function generateLinesArray(lineRanges) {
/* Generates an snippet lines array like this:
availableLineRanges: [{from: 1, to: 4}]
Return value: [
{number: 1, content 'L1'},
{number: 2, content 'L2'},
{number: 3, content 'L3'},
{number: 4, content 'L4'}
];
*/
function generateLinesArray(availableLineRanges) {
const lines = [];
lineRanges.forEach(({from, to}) => {
availableLineRanges.forEach(({from, to}) => {
for (let i = from; i <= to; i++) {
lines.push({
lineNumber: i,
Expand All @@ -35,14 +44,14 @@ function generateLinesArray(lineRanges) {
function makeSnippetDetails({
lineMessages,
generalMessages,
lineRanges,
availableLineRanges,
title = 'Snippet',
lineCount,
}) {
return {
type: 'snippet',
title: title,
lines: generateLinesArray(lineRanges),
lines: generateLinesArray(availableLineRanges),
lineMessages,
generalMessages,
lineCount,
Expand Down Expand Up @@ -95,7 +104,7 @@ describe('DetailsRenderer', () => {
},
],
generalMessages: [],
lineRanges: [{from: 1, to: 6}],
availableLineRanges: [{from: 1, to: 6}],
lineCount: 100,
});
const {contentLines, messageLines, collapsedContentLines} = renderSnippet(details);
Expand All @@ -117,7 +126,7 @@ describe('DetailsRenderer', () => {
const details = makeSnippetDetails({
lineMessages: [],
generalMessages: [],
lineRanges: [{from: 1, to: 6}],
availableLineRanges: [{from: 1, to: 6}],
lineCount: 100,
});
const {
Expand All @@ -142,7 +151,7 @@ describe('DetailsRenderer', () => {
message: 'General error',
},
],
lineRanges: [{from: 1, to: 6}],
availableLineRanges: [{from: 1, to: 6}],
lineCount: 100,
});
const {uncollapsedContentLines, messageLines} = renderSnippet(details);
Expand All @@ -168,7 +177,7 @@ describe('DetailsRenderer', () => {
},
],
generalMessages: [],
lineRanges: [
availableLineRanges: [
{
from: 30,
to: 50,
Expand Down Expand Up @@ -208,7 +217,7 @@ describe('DetailsRenderer', () => {
message: 'General error',
},
],
lineRanges: [{from: 1, to: 6}],
availableLineRanges: [{from: 1, to: 6}],
lineCount: 100,
});
const {messageLines} = renderSnippet(details);
Expand All @@ -221,7 +230,7 @@ describe('DetailsRenderer', () => {
title: 'Test Snippet',
lineMessages: [],
generalMessages: [],
lineRanges: [{from: 1, to: 6}],
availableLineRanges: [{from: 1, to: 6}],
lineCount: 100,
});
const {title, toggleExpandButton, el} = renderSnippet(details);
Expand All @@ -242,7 +251,7 @@ describe('DetailsRenderer', () => {
lineMessages: [],
generalMessages: [],
// We show all 5 lines by default, so there's nothing to expand
lineRanges: [{from: 1, to: 5}],
availableLineRanges: [{from: 1, to: 5}],
});
const {toggleExpandButton} = renderSnippet(details);

Expand Down

0 comments on commit 8aa311d

Please sign in to comment.