mirror of
https://github.com/hanzoai/gui.git
synced 2026-10-25 02:31:41 +00:00
Internal renames so source matches the published @hanzogui/[email protected] dist (Gui.ts, createGui.ts, views/GuiProvider.mjs, views/GuiRoot.mjs). Renames applied: - Files: Hanzogui.ts -> Gui.ts, createHanzogui.ts -> createGui.ts, HanzoguiProvider.tsx -> GuiProvider.tsx, HanzoguiRoot[.native].tsx -> GuiRoot[.native].tsx, HanzoguiPlugin.ts -> GuiPlugin.ts, withHanzogui.ts -> withGui.ts, loadHanzogui.ts -> loadGui.ts, v4-hanzogui.ts -> v4-gui.ts, *.d.ts mirrors, hanzogui.config.ts -> gui.config.ts, hanzogui.build.ts -> gui.build.ts, hanzogui.css -> gui.css, hanzogui-build.js -> gui-build.js, etc. - Directories: pkgs/core/create-hanzogui -> pkgs/core/create-gui, apps/sandbox/config/hanzogui -> apps/sandbox/config/gui. - Identifiers: Hanzogui* -> Gui*, createHanzogui -> createGui, withHanzogui -> withGui, loadHanzogui -> loadGui, HANZOGUI_* env -> GUI_*, __hanzogui* globals -> __gui*, hanzoguiOptions/hanzoguiConfig/ hanzoguiPlugin etc. -> guiOptions/guiConfig/guiPlugin, CSS vars --hanzogui-* -> --gui-*, data-hanzogui-* -> data-gui-*, [hanzogui] log prefix -> [gui]. - Removed duplicate pkgs/packages/hanzogui-dev-config; the canonical pkgs/packages/gui-dev-config (@hanzogui/dev-config) already existed with the correct shape. apps/demos now consumes @hanzogui/dev-config. Preserved (public npm names): - "hanzogui" umbrella package (pkgs/ui/hanzogui/package.json) - "@hanzogui/*" namespace - "hanzogui-loader" package name (pkgs/compiler/loader) - "hanzogui-build-test-*" test fixture names - "hanzogui-publish-smoke" workflow id - pkgs/core/helpers-hanzogui dir (not on rename list) - apps/gui.hanzo.ai/ marketing site directory - AGENTS.md symlink restored after perl -i clobbered it Smoke build (turbo run build): 169/169 workspaces successful. Sample tests: pkgs/core/core-test getSplitStyles.android* + createGui.web all green.
74 lines
2.0 KiB
TypeScript
74 lines
2.0 KiB
TypeScript
import '@testing-library/jest-dom'
|
|
import 'vitest-axe/extend-expect'
|
|
|
|
import { Button } from '@hanzogui/button'
|
|
import { getDefaultGuiConfig } from '@hanzogui/config-default'
|
|
import { View, GuiProvider, createGui } from '@hanzogui/core'
|
|
import type { RenderResult } from '@testing-library/react'
|
|
import { render } from '@testing-library/react'
|
|
import { beforeEach, describe, expect, it } from 'vitest'
|
|
|
|
const conf = createGui(getDefaultGuiConfig())
|
|
|
|
function ButtonTest(props: React.ComponentProps<typeof Button>) {
|
|
return (
|
|
<GuiProvider config={conf} defaultTheme="light">
|
|
<View>
|
|
<Button {...props} />
|
|
</View>
|
|
</GuiProvider>
|
|
)
|
|
}
|
|
|
|
const BUTTON_ROLE = 'button'
|
|
|
|
global.ResizeObserver = class ResizeObserver {
|
|
cb: any
|
|
constructor(cb: any) {
|
|
this.cb = cb
|
|
}
|
|
observe() {
|
|
this.cb([{ borderBoxSize: { inlineSize: 0, blockSize: 0 } }])
|
|
}
|
|
unobserve() {}
|
|
disconnect() {}
|
|
}
|
|
|
|
describe('Button with Button.Text for font styling', () => {
|
|
let rendered: RenderResult
|
|
let button: HTMLElement
|
|
let buttonText: HTMLElement
|
|
|
|
beforeEach(() => {
|
|
rendered = render(
|
|
<ButtonTest>
|
|
<Button.Text fontFamily="$heading">Test</Button.Text>
|
|
</ButtonTest>
|
|
)
|
|
button = rendered.getByRole(BUTTON_ROLE)
|
|
buttonText = rendered.getByText('Test')
|
|
})
|
|
|
|
it('should display the button text with the correct font-family class', async () => {
|
|
expect(buttonText).toHaveClass('font_heading')
|
|
})
|
|
})
|
|
|
|
describe('Button basic functionality', () => {
|
|
it('should render a button element', () => {
|
|
const { getByRole } = render(<ButtonTest>Click me</ButtonTest>)
|
|
expect(getByRole(BUTTON_ROLE)).toBeTruthy()
|
|
})
|
|
|
|
it('should display button text', () => {
|
|
const { getByText } = render(<ButtonTest>Click me</ButtonTest>)
|
|
expect(getByText('Click me')).toBeTruthy()
|
|
})
|
|
|
|
it('should be focusable', () => {
|
|
const { getByRole } = render(<ButtonTest>Click me</ButtonTest>)
|
|
const button = getByRole(BUTTON_ROLE)
|
|
expect(button).toHaveAttribute('tabindex', '0')
|
|
})
|
|
})
|