|
1 | 1 | /** |
2 | 2 | * @vitest-environment jsdom |
3 | 3 | */ |
4 | | -import { act } from 'react' |
| 4 | +import { act, createRef } from 'react' |
5 | 5 | import { sleep } from '@sim/utils/helpers' |
6 | 6 | import { createRoot, type Root } from 'react-dom/client' |
7 | 7 | import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' |
@@ -114,4 +114,34 @@ describe('Code.Viewer appearances', () => { |
114 | 114 | expect(flatViewer.classList.contains('dark:bg-[var(--bg)]')).toBe(true) |
115 | 115 | expect(flatViewer.textContent).toContain('flat') |
116 | 116 | }) |
| 117 | + |
| 118 | + it('applies flat chrome on the virtualized gutter path used by the terminal', async () => { |
| 119 | + const contentRef = createRef<HTMLDivElement>() |
| 120 | + await act(async () => { |
| 121 | + root?.render( |
| 122 | + <Code.Viewer |
| 123 | + code={'first line\nsecond line'} |
| 124 | + language='json' |
| 125 | + appearance='flat' |
| 126 | + className='m-0 min-h-full' |
| 127 | + showGutter |
| 128 | + virtualized |
| 129 | + wrapText |
| 130 | + paddingLeft={8} |
| 131 | + contentRef={contentRef} |
| 132 | + /> |
| 133 | + ) |
| 134 | + await sleep(1) |
| 135 | + }) |
| 136 | + |
| 137 | + const viewer = host?.firstElementChild |
| 138 | + expect(contentRef.current).toBe(viewer) |
| 139 | + expect(viewer?.classList.contains('rounded-none')).toBe(true) |
| 140 | + expect(viewer?.classList.contains('border-0')).toBe(true) |
| 141 | + expect(viewer?.classList.contains('bg-[var(--bg)]')).toBe(true) |
| 142 | + expect(viewer?.classList.contains('dark:bg-[var(--bg)]')).toBe(true) |
| 143 | + expect(viewer?.classList.contains('overflow-x-hidden')).toBe(true) |
| 144 | + expect(viewer?.classList.contains('min-h-full')).toBe(true) |
| 145 | + expect(viewer?.classList.contains('rounded-sm')).toBe(false) |
| 146 | + }) |
117 | 147 | }) |
0 commit comments