d7fb7b7a7b
Build & Deploy / Build & Push Docker Image (push) Failing after 47s
Build & Deploy / Deploy to VPS (push) Has been skipped
Test / API Unit Tests (push) Failing after 5m4s
Test / Marketplace Unit Tests (push) Failing after 4m55s
Test / Admin Unit Tests (push) Successful in 9m37s
Test / Dashboard Unit Tests (push) Successful in 9m37s
Test / API Integration Tests (push) Successful in 9m54s
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import React, { isValidElement } from 'react'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
vi.mock('./PublicNavbar', () => ({ default: function MockPublicNavbar() { return React.createElement('mock-navbar') } }))
|
|
vi.mock('./PublicFooter', () => ({ default: function MockPublicFooter() { return React.createElement('mock-footer') } }))
|
|
|
|
import PublicPageLayout from './PublicPageLayout'
|
|
|
|
function childTypes(node: React.ReactElement): string[] {
|
|
return React.Children.toArray(node.props.children).filter(isValidElement).map((child) => {
|
|
const type = child.type as any
|
|
return typeof type === 'string' ? type : type.displayName ?? type.name ?? 'anonymous'
|
|
})
|
|
}
|
|
|
|
describe('PublicPageLayout', () => {
|
|
it('provides reusable public chrome for sign-in and account creation pages', () => {
|
|
const layout = PublicPageLayout({ children: React.createElement('main') })
|
|
|
|
expect(childTypes(layout)).toEqual(['MockPublicNavbar', 'div', 'MockPublicFooter'])
|
|
expect(layout.props['data-public-page-layout']).toBe('true')
|
|
})
|
|
|
|
it('allows either public chrome region to be disabled independently', () => {
|
|
const layout = PublicPageLayout({
|
|
children: React.createElement('main'),
|
|
showNavbar: false,
|
|
showFooter: true,
|
|
})
|
|
|
|
expect(childTypes(layout)).toEqual(['div', 'MockPublicFooter'])
|
|
})
|
|
})
|