diff --git a/src/__tests__/diff2html-tests.ts b/src/__tests__/diff2html-tests.ts index 5591a61..ef68562 100644 --- a/src/__tests__/diff2html-tests.ts +++ b/src/__tests__/diff2html-tests.ts @@ -1260,7 +1260,7 @@ describe('Diff2Html', () => { }); describe('with auto colorScheme', () => { - it('should return a html diff with dark mode', () => { + it('should return a html diff with auto color scheme', () => { const result = html(diffExample1, { drawFileList: false, colorScheme: ColorSchemeType.AUTO, @@ -1319,6 +1319,86 @@ describe('Diff2Html', () => { " `); }); + + it('should include auto mode on file list', () => { + const result = html(diffExample1, { + drawFileList: true, + colorScheme: ColorSchemeType.AUTO, + }); + expect(result).toMatchInlineSnapshot(` + "
+
+ Files changed (1) + hide + show +
+
    +
  1. + + sample + + +1 + -1 + + +
  2. +
+
+
+
+ + sample + CHANGED + +
+
+
+ + + + + + + + + + + + + +
+
@@ -1 +1 @@
+
+
1
+
+
+
+ - + test +
+
+
+
1
+
+
+ + + test1 +
+
+
+
+
+
" + `); + }); }); describe('with dark colorScheme', () => { @@ -1381,6 +1461,86 @@ describe('Diff2Html', () => { " `); }); + + it('should include dark mode on file list', () => { + const result = html(diffExample1, { + drawFileList: true, + colorScheme: ColorSchemeType.DARK, + }); + expect(result).toMatchInlineSnapshot(` + "
+
+ Files changed (1) + hide + show +
+
    +
  1. + + sample + + +1 + -1 + + +
  2. +
+
+
+
+ + sample + CHANGED + +
+
+
+ + + + + + + + + + + + + +
+
@@ -1 +1 @@
+
+
1
+
+
+
+ - + test +
+
+
+
1
+
+
+ + + test1 +
+
+
+
+
+
" + `); + }); }); }); }); diff --git a/src/diff2html.ts b/src/diff2html.ts index 8da24c7..06f00f7 100644 --- a/src/diff2html.ts +++ b/src/diff2html.ts @@ -32,7 +32,10 @@ export function html(diffInput: string | DiffFile[], configuration: Diff2HtmlCon const hoganUtils = new HoganJsUtils(config); - const fileList = config.drawFileList ? new FileListRenderer(hoganUtils).render(diffJson) : ''; + const { colorScheme } = config; + const fileListRendererConfig = { colorScheme }; + + const fileList = config.drawFileList ? new FileListRenderer(hoganUtils, fileListRendererConfig).render(diffJson) : ''; const diffOutput = config.outputFormat === 'side-by-side'