fix: allow runtime stylesheet injection

This commit is contained in:
lucaronin
2026-04-25 16:06:17 +02:00
parent 8207b87c33
commit 3ebfa642fa
4 changed files with 13 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { renderHook, act } from '@testing-library/react'
import { CODEMIRROR_CSP_NONCE, useCodeMirror, type CodeMirrorCallbacks } from './useCodeMirror'
import { useCodeMirror, type CodeMirrorCallbacks } from './useCodeMirror'
const noop = () => {}
const noopCallbacks: CodeMirrorCallbacks = {
@@ -31,14 +31,6 @@ describe('useCodeMirror', () => {
expect(container.querySelector('.cm-editor')).toBeInTheDocument()
})
it('mounts CodeMirror generated styles with the configured CSP nonce', () => {
const ref = { current: container }
renderHook(() => useCodeMirror(ref, 'hello', noopCallbacks))
const style = document.head.querySelector(`style[nonce="${CODEMIRROR_CSP_NONCE}"]`)
expect(style?.textContent).toContain('.cm-scroller')
})
it('calls requestMeasure when laputa-zoom-change event fires', () => {
const ref = { current: container }
const { result } = renderHook(() =>