import * as assert from 'remix/assert'
import { describe, it } from 'remix/test'
import { renderToString } from 'remix/component/server'
import { createDocsNavigationLinks, DocsHeader } from './docs-header.tsx'
import type { DocsNavigationLink } from './docs-header.tsx'
const navigationLinks = [
{ href: '/guides', label: 'Guides', current: 'location' },
{ href: '/api', label: 'API' },
] satisfies readonly DocsNavigationLink[]
describe('createDocsNavigationLinks', () => {
it('returns the six absolute links in navigation order', () => {
let links = createDocsNavigationLinks()
assert.deepEqual(
[...links],
[
['docs', { href: 'https://docs.remix.run', label: 'Docs' }],
['github', { href: 'https://github.com/remix-run/remix', label: 'GitHub' }],
['blog', { href: 'https://remix.run/blog', label: 'Blog' }],
['newsletter', { href: 'https://remix.run/newsletter', label: 'Newsletter' }],
['jam', { href: 'https://remix.run/jam/2026', label: 'Jam' }],
['store', { href: 'https://shop.remix.run', label: 'Store' }],
],
)
})
it('retains order when a caller replaces an existing link', () => {
let links = createDocsNavigationLinks()
links.set('docs', { href: '/v3', label: 'Docs', current: 'page' })
assert.deepEqual(
[...links.values()].map((link) => link.label),
['Docs', 'GitHub', 'Blog', 'Newsletter', 'Jam', 'Store'],
)
assert.deepEqual(links.get('docs'), { href: '/v3', label: 'Docs', current: 'page' })
})
})
describe('DocsHeader', () => {
it('renders the Remix brand and a native mobile menu', async () => {
let html = await renderToString(
,
)
assert.doesNotMatch(html, /id="docs-navigation-toggle"/)
assert.match(html, /id="site-menu-toggle"[^>]*popovertarget="site-primary-navigation"/)
assert.match(html, /id="site-primary-navigation"[^>]*popover="auto"/)
assert.equal(html.match(/>Guides<\/a>/g)?.length, 2)
assert.equal(html.match(/href="\/guides"[^>]*aria-current="location"/g)?.length, 2)
assert.match(
html,
/id="docs-brand"[^>]*href="https:\/\/remix\.run"[^>]*aria-label="Remix Docs"/,
)
assert.equal(html.match(/id="docs-search-button"/g)?.length, 1)
assert.doesNotMatch(html, /class="[^"]*site-header/)
assert.doesNotMatch(html, /\[object Object\]/)
})
it('shows the mobile menu only while its popover is open, without animating', async () => {
let html = await renderToString(
,
)
assert.match(html, /&:popover-open \{\s*display: flex;/)
assert.doesNotMatch(html, /@starting-style/)
assert.doesNotMatch(html, /transition-behavior: allow-discrete/)
})
it('renders one responsive search trigger for Pagefind focus ownership', async () => {
let html = await renderToString(
,
)
assert.doesNotMatch(html, /