|
1 | 1 | import { FileListRenderer } from '../file-list-renderer'; |
2 | 2 | import HoganJsUtils from '../hoganjs-utils'; |
| 3 | +import { ColorSchemeType } from '../types'; |
3 | 4 |
|
4 | 5 | describe('FileListRenderer', () => { |
5 | 6 | describe('render', () => { |
@@ -175,5 +176,97 @@ describe('FileListRenderer', () => { |
175 | 176 | </div>" |
176 | 177 | `); |
177 | 178 | }); |
| 179 | + |
| 180 | + describe('with dark colorScheme', () => { |
| 181 | + it('should work for all kinds of files', () => { |
| 182 | + const hoganUtils = new HoganJsUtils({}); |
| 183 | + const fileListRenderer = new FileListRenderer(hoganUtils, { |
| 184 | + colorScheme: ColorSchemeType.DARK, |
| 185 | + }); |
| 186 | + |
| 187 | + const files = [ |
| 188 | + { |
| 189 | + isCombined: false, |
| 190 | + isGitDiff: false, |
| 191 | + blocks: [], |
| 192 | + addedLines: 12, |
| 193 | + deletedLines: 41, |
| 194 | + language: 'js', |
| 195 | + oldName: 'my/file/name.js', |
| 196 | + newName: 'my/file/name.js', |
| 197 | + }, |
| 198 | + ]; |
| 199 | + const fileHtml = fileListRenderer.render(files); |
| 200 | + expect(fileHtml).toMatchInlineSnapshot(` |
| 201 | + "<div class="d2h-file-list-wrapper d2h-dark-color-scheme"> |
| 202 | + <div class="d2h-file-list-header"> |
| 203 | + <span class="d2h-file-list-title">Files changed (1)</span> |
| 204 | + <a class="d2h-file-switch d2h-hide">hide</a> |
| 205 | + <a class="d2h-file-switch d2h-show">show</a> |
| 206 | + </div> |
| 207 | + <ol class="d2h-file-list"> |
| 208 | + <li class="d2h-file-list-line"> |
| 209 | + <span class="d2h-file-name-wrapper"> |
| 210 | + <svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1" |
| 211 | + viewBox="0 0 14 16" width="14"> |
| 212 | + <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path> |
| 213 | + </svg> <a href="#d2h-781444" class="d2h-file-name">my/file/name.js</a> |
| 214 | + <span class="d2h-file-stats"> |
| 215 | + <span class="d2h-lines-added">+12</span> |
| 216 | + <span class="d2h-lines-deleted">-41</span> |
| 217 | + </span> |
| 218 | + </span> |
| 219 | + </li> |
| 220 | + </ol> |
| 221 | + </div>" |
| 222 | + `); |
| 223 | + }); |
| 224 | + }); |
| 225 | + |
| 226 | + describe('with auto colorScheme', () => { |
| 227 | + it('should work for all kinds of files', () => { |
| 228 | + const hoganUtils = new HoganJsUtils({}); |
| 229 | + const fileListRenderer = new FileListRenderer(hoganUtils, { |
| 230 | + colorScheme: ColorSchemeType.AUTO, |
| 231 | + }); |
| 232 | + |
| 233 | + const files = [ |
| 234 | + { |
| 235 | + isCombined: false, |
| 236 | + isGitDiff: false, |
| 237 | + blocks: [], |
| 238 | + addedLines: 12, |
| 239 | + deletedLines: 41, |
| 240 | + language: 'js', |
| 241 | + oldName: 'my/file/name.js', |
| 242 | + newName: 'my/file/name.js', |
| 243 | + }, |
| 244 | + ]; |
| 245 | + const fileHtml = fileListRenderer.render(files); |
| 246 | + expect(fileHtml).toMatchInlineSnapshot(` |
| 247 | + "<div class="d2h-file-list-wrapper d2h-auto-color-scheme"> |
| 248 | + <div class="d2h-file-list-header"> |
| 249 | + <span class="d2h-file-list-title">Files changed (1)</span> |
| 250 | + <a class="d2h-file-switch d2h-hide">hide</a> |
| 251 | + <a class="d2h-file-switch d2h-show">show</a> |
| 252 | + </div> |
| 253 | + <ol class="d2h-file-list"> |
| 254 | + <li class="d2h-file-list-line"> |
| 255 | + <span class="d2h-file-name-wrapper"> |
| 256 | + <svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1" |
| 257 | + viewBox="0 0 14 16" width="14"> |
| 258 | + <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path> |
| 259 | + </svg> <a href="#d2h-781444" class="d2h-file-name">my/file/name.js</a> |
| 260 | + <span class="d2h-file-stats"> |
| 261 | + <span class="d2h-lines-added">+12</span> |
| 262 | + <span class="d2h-lines-deleted">-41</span> |
| 263 | + </span> |
| 264 | + </span> |
| 265 | + </li> |
| 266 | + </ol> |
| 267 | + </div>" |
| 268 | + `); |
| 269 | + }); |
| 270 | + }); |
178 | 271 | }); |
179 | 272 | }); |
0 commit comments