Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

test(ui): cover ref-less hover animation on the animated icon primitive

thinhlpg2b5f002ff084
diff --git a/web-app/src/components/animated-icon/__tests__/animated-lucide.test.tsx b/web-app/src/components/animated-icon/__tests__/animated-lucide.test.tsx
index 31f4dcf43..1a798bee3 100644
--- a/web-app/src/components/animated-icon/__tests__/animated-lucide.test.tsx
+++ b/web-app/src/components/animated-icon/__tests__/animated-lucide.test.tsx
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom/vitest'
import { createRef, type HTMLAttributes, type ReactNode } from 'react'
-import { act, render, screen } from '@testing-library/react'
+import { act, fireEvent, render, screen } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'
import type { LucideIcon } from 'lucide-react'
@@ -68,6 +68,22 @@ describe('AnimatedLucideIcon', () => {
expect(motionState.start).toHaveBeenNthCalledWith(2, 'normal')
})
+ it('self-animates on hover when the caller supplies no ref', () => {
+ render(
+ <AnimatedLucideIcon
+ icon={MockIcon}
+ preset="home"
+ data-testid="icon-wrapper"
+ />
+ )
+
+ fireEvent.mouseEnter(screen.getByTestId('icon-wrapper'))
+ fireEvent.mouseLeave(screen.getByTestId('icon-wrapper'))
+
+ expect(motionState.start).toHaveBeenNthCalledWith(1, 'animate')
+ expect(motionState.start).toHaveBeenNthCalledWith(2, 'normal')
+ })
+
it('does not start transforms when reduced motion is enabled', () => {
motionState.reduced = true
const ref = createRef<AnimatedLucideIconHandle>()