Skip to content

Commit b2d13f4

Browse files
committed
test(ui): cover strict mode overflow replay
1 parent 894a8dc commit b2d13f4

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

packages/emcn/src/components/overflow-text/overflow-text.test.tsx

Lines changed: 19 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, StrictMode } from 'react'
55
import { createRoot, type Root } from 'react-dom/client'
66
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
77
import { OverflowText } from './overflow-text'
@@ -227,4 +227,22 @@ describe('OverflowText', () => {
227227
act(() => document.fonts.dispatchEvent(new Event('loadingerror')))
228228
expect(label.className).not.toContain('mask-image:linear-gradient')
229229
})
230+
231+
it('keeps observing mounted labels through Strict Mode effect replay', () => {
232+
act(() =>
233+
root.render(
234+
<StrictMode>
235+
<OverflowText label='Workflow name' />
236+
</StrictMode>
237+
)
238+
)
239+
const label = host.querySelector<HTMLElement>('span')
240+
if (!label) throw new Error('Overflow label did not render')
241+
242+
setWidths(label, 100, 60)
243+
Object.defineProperty(label, 'scrollWidth', { configurable: true, value: 180 })
244+
act(() => document.fonts.dispatchEvent(new Event('loadingdone')))
245+
246+
expect(label.className).toContain('mask-image:linear-gradient')
247+
})
230248
})

0 commit comments

Comments
 (0)