import { describe, it, expect, vi } from 'vitest' import type { App } from 'vue' import { createNychthemeron, LoadingIcon, Checkbox, RadioButton, CheckboxGroup, RadioButtonGroup, Select, Card, Dialog, Message, } from '../src/index' //eslint-disable-next-line const callSetup = (component: any, props: Record) => { const mergedProps: Record = {} if (component.props) { for (const [key, propDef] of Object.entries(component.props)) { if (typeof propDef === 'object' && propDef !== null && 'default' in propDef) { mergedProps[key] = (propDef as { default: unknown }).default } } } Object.assign(mergedProps, props) if (component.setup) { const result = component.setup(mergedProps, { slots: {}, attrs: {} }) if (typeof result === 'function') { const vnode = result() return (vnode?.props as Record) || {} } return result } return mergedProps } describe('createNychthemeron', () => { it('returns a Vue plugin with install method', () => { const plugin = createNychthemeron() expect(typeof plugin.install).toBe('function') }) it('install registers NychButton and NychLoadingIcon globally', () => { const plugin = createNychthemeron() const mockApp = { component: vi.fn() } as unknown as App plugin.install(mockApp) expect(mockApp.component).toHaveBeenCalledWith('NychButton', expect.anything()) expect(mockApp.component).toHaveBeenCalledWith('NychLoadingIcon', expect.anything()) }) it('exposes Button and LoadingIcon components', () => { const { Button: btn, LoadingIcon: icon } = createNychthemeron() expect(btn).toBeDefined() expect(icon).toBeDefined() }) }) describe('LoadingIcon', () => { it('is a valid Vue component', () => { expect(LoadingIcon).toBeDefined() }) }) describe('themed pt components', () => { const cases = [ { name: 'Checkbox', component: Checkbox, base: 'nych-checkbox' }, { name: 'CheckboxGroup', component: CheckboxGroup, base: 'nych-checkbox-group' }, { name: 'RadioButton', component: RadioButton, base: 'nych-radio' }, { name: 'RadioButtonGroup', component: RadioButtonGroup, base: 'nych-radio-group' }, { name: 'Select', component: Select, base: 'nych-select' }, { name: 'Card', component: Card, base: 'nych-card' }, { name: 'Dialog', component: Dialog, base: 'nych-dialog' }, { name: 'Message', component: Message, base: 'nych-message' }, ] it.each(cases)('$name is a valid Vue component', ({ component }) => { expect(component).toBeDefined() expect(typeof (component as Record).setup).toBe('function') }) it.each(cases)('$name injects its base class onto pt.root', ({ component, base }) => { const result = callSetup(component, { pt: {} }) expect(result.pt?.root?.class).toContain(base) }) it.each(cases)('$name does not leak engine internal props', ({ component }) => { const result = callSetup(component, { pt: {} }) expect(result).not.toHaveProperty('injectedClasses') expect(result).not.toHaveProperty('injectedStyles') expect(result).not.toHaveProperty('stylePlug') }) it('Checkbox themes its box, input and icon sections', () => { const result = callSetup(Checkbox, { pt: {} }) expect(result.pt?.box?.class).toContain('nych-checkbox-box') expect(result.pt?.input?.class).toContain('nych-checkbox-input') expect(result.pt?.icon?.class).toContain('nych-checkbox-icon') }) it('Select themes its overlay and option sections', () => { const result = callSetup(Select, { pt: {} }) expect(result.pt?.overlay?.class).toContain('nych-select-overlay') expect(result.pt?.option?.class).toContain('nych-select-option') }) })