Skip to content

Commit dffc482

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
Test flat virtualized Code.Viewer terminal chrome
1 parent 03c23d5 commit dffc482

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

‎packages/emcn/src/components/code/code.test.tsx‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @vitest-environment jsdom
33
*/
4-
import { act } from 'react'
4+
import { act, createRef } from 'react'
55
import { sleep } from '@sim/utils/helpers'
66
import { createRoot, type Root } from 'react-dom/client'
77
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
@@ -114,4 +114,34 @@ describe('Code.Viewer appearances', () => {
114114
expect(flatViewer.classList.contains('dark:bg-[var(--bg)]')).toBe(true)
115115
expect(flatViewer.textContent).toContain('flat')
116116
})
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+
})
117147
})

0 commit comments

Comments
 (0)