Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/llms-txt-hub / apps/web/components/__tests__/json-ld.test.tsx |
| Date | Not specified in source |
| Repository | Janady13/llms-txt-hub |
| Revision | e0f4bf978d4df168369c7601d9c5f5ea89e84377 |
| Branch | main |
| Path or archive member | apps/web/components/__tests__/json-ld.test.tsx |
| Original SHA-256 | 77bf53ed3e469ed5e140547f8a616261310498f891a132c421a11b5c6aa27db4 |
| Git blob SHA | a41cd15a58fe304e23051ddc89716d9a77c7c39b |
| Reading-copy SHA-256 | 77bf53ed3e469ed5e140547f8a616261310498f891a132c421a11b5c6aa27db4 |
Recovered source transcript
Download complete source text ↓34 lines · 1.0 KB
import { headers } from 'next/headers'
import React from 'react'
import { JsonLd } from '@/components/json-ld'
jest.mock('next/headers', () => ({
headers: jest.fn()
}))
describe('JsonLd', () => {
const mockedHeaders = headers as jest.MockedFunction<typeof headers>
beforeEach(() => {
jest.clearAllMocks()
})
it('marks nonce-backed JSON-LD scripts to suppress hydration mismatches', async () => {
mockedHeaders.mockResolvedValue(
new Headers({ 'x-nonce': 'test-nonce' }) as Awaited<ReturnType<typeof headers>>
)
const scriptElement = await JsonLd({
data: {
'@context': 'https://schema.org',
name: 'Example <script>alert(1)</script>'
}
})
expect(React.isValidElement(scriptElement)).toBe(true)
expect(scriptElement.props.nonce).toBe('test-nonce')
expect(scriptElement.props.suppressHydrationWarning).toBe(true)
expect(scriptElement.props.dangerouslySetInnerHTML.__html).toContain('\\u003cscript>')
})
})