Skip to content

Commit cac4325

Browse files
committed
feat(detector): adds color to files with smells
1 parent cf7c31f commit cac4325

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

detector/src/reporters/layout/example.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ <h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white"
8383
{{#each data}}
8484
<tr
8585
onclick="toggleDetails({{@index}})"
86-
class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700 cursor-pointer">
86+
87+
{{#if smells.length}}
88+
class="odd:bg-white odd:bg-yellow-400 even:bg-yellow-400 border-b even:dark:bg-yellow-800 odd:dark:bg-yellow-800 cursor-pointer"
89+
{{else}}
90+
class="odd:bg-white odd:dark:bg-gray-900 even:bg-gray-50 even:dark:bg-gray-800 border-b dark:border-gray-700 cursor-pointer"
91+
{{/if}}
92+
>
8793
<th scope="row" class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
8894
{{this.fileName}}
8995
</th>

detector/test/html-report.integration.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ describe('html report', () => {
116116
expect(root.querySelector('[data-testid="file-list"] tbody tr')?.textContent).toContain('javascript');
117117
});
118118

119+
test('renders yellow line when smells exists', async () => {
120+
const generatedHtml = await buildHtmlReportForTestSmellsFor(exportsOptions, filePath, oneFileWithOneConsoleSmells());
121+
const root = parse(generatedHtml);
122+
123+
expect(root.querySelector('[data-testid="file-list"] tbody tr')?.classList.value).toContain('odd:bg-yellow-400');
124+
expect(root.querySelector('[data-testid="file-list"] tbody tr')?.classList.value).toContain('even:bg-yellow-400');
125+
});
126+
127+
test('should not render yellow for file without smells', async () => {
128+
const generatedHtml = await buildHtmlReportForTestSmellsFor(exportsOptions, filePath, emptySmellsListForSingleFile());
129+
const root = parse(generatedHtml);
130+
131+
expect(root.querySelector('[data-testid="file-list"] tbody tr')?.classList.value).not.toContain('odd:bg-yellow-400');
132+
expect(root.querySelector('[data-testid="file-list"] tbody tr')?.classList.value).not.toContain('even:bg-yellow-400');
133+
});
134+
119135
describe('smells table with smells', () => {
120136
test('renders info about no smells', async () => {
121137
const generatedHtml = await buildHtmlReportForTestSmellsFor(exportsOptions, filePath, emptySmellsListForSingleFile());

0 commit comments

Comments
 (0)