2026-03-03 02:31:10 +01:00
|
|
|
import { render, screen, fireEvent } from '@testing-library/react'
|
|
|
|
|
import { describe, it, expect, vi } from 'vitest'
|
|
|
|
|
import { ArchivedNoteBanner } from './ArchivedNoteBanner'
|
|
|
|
|
|
|
|
|
|
describe('ArchivedNoteBanner', () => {
|
|
|
|
|
it('renders archive icon and label', () => {
|
|
|
|
|
render(<ArchivedNoteBanner onUnarchive={vi.fn()} />)
|
|
|
|
|
expect(screen.getByTestId('archived-note-banner')).toBeTruthy()
|
|
|
|
|
expect(screen.getByText('Archived')).toBeTruthy()
|
|
|
|
|
})
|
|
|
|
|
|
2026-04-10 12:08:17 +02:00
|
|
|
it('renders unarchive button without the stale archive shortcut hint', () => {
|
2026-03-03 02:31:10 +01:00
|
|
|
render(<ArchivedNoteBanner onUnarchive={vi.fn()} />)
|
|
|
|
|
const btn = screen.getByTestId('unarchive-btn')
|
|
|
|
|
expect(btn).toBeTruthy()
|
|
|
|
|
expect(btn.textContent).toContain('Unarchive')
|
2026-04-10 12:08:17 +02:00
|
|
|
expect(btn.title).toBe('Unarchive')
|
2026-03-03 02:31:10 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('calls onUnarchive when button is clicked', () => {
|
|
|
|
|
const onUnarchive = vi.fn()
|
|
|
|
|
render(<ArchivedNoteBanner onUnarchive={onUnarchive} />)
|
|
|
|
|
fireEvent.click(screen.getByTestId('unarchive-btn'))
|
|
|
|
|
expect(onUnarchive).toHaveBeenCalledOnce()
|
|
|
|
|
})
|
|
|
|
|
})
|