import { describe, it, expect, vi } from 'vitest' import { render } from '@testing-library/react' import ChartContainer from '@/components/ChartContainer' describe('ChartContainer', () => { it('should call onInit with container element on mount', () => { const onInit = vi.fn() render() expect(onInit).toHaveBeenCalledTimes(1) expect(onInit).toHaveBeenCalledWith(expect.any(HTMLElement)) }) it('should call onDestroy on unmount', () => { const onDestroy = vi.fn() const onInit = vi.fn() const { unmount } = render() expect(onDestroy).not.toHaveBeenCalled() unmount() expect(onDestroy).toHaveBeenCalledTimes(1) }) it('should not crash when onDestroy is not provided', () => { const onInit = vi.fn() const { unmount } = render() expect(() => unmount()).not.toThrow() }) it('should apply custom style', () => { const onInit = vi.fn() const { container } = render( ) const div = container.firstChild as HTMLElement expect(div.style.backgroundColor).toBe('red') }) it('should have default width and height 100%', () => { const onInit = vi.fn() const { container } = render() const div = container.firstChild as HTMLElement expect(div.style.width).toBe('100%') expect(div.style.height).toBe('100%') }) })