+5
![dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)
![autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>](/assets/img/avatar_default.png)







Jingyi
GitHub
yyh
Joel
hjlarry
fatelei
Asuka Minato
autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Xiyuan Chen
gigglewang
Yunlu Wen
chariri
Evan
yyh
9b74df21d0
Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: yyh <[email protected]> Co-authored-by: Joel <[email protected]> Co-authored-by: hjlarry <[email protected]> Co-authored-by: fatelei <[email protected]> Co-authored-by: Asuka Minato <[email protected]> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Xiyuan Chen <[email protected]> Co-authored-by: gigglewang <[email protected]> Co-authored-by: Yunlu Wen <[email protected]> Co-authored-by: chariri <[email protected]> Co-authored-by: Evan <[email protected]> Co-authored-by: yyh <[email protected]>
60 lines
2.1 KiB
TypeScript
60 lines
2.1 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import * as React from 'react'
|
|
import Empty from '../empty'
|
|
|
|
const defaultMessage = 'workflow.tabs.noSnippetsFound'
|
|
|
|
describe('Empty', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
describe('Rendering', () => {
|
|
it('should render without crashing', () => {
|
|
render(<Empty message={defaultMessage} />)
|
|
expect(screen.getByText(defaultMessage)).toBeInTheDocument()
|
|
})
|
|
|
|
it('should render 16 placeholder cards', () => {
|
|
const { container } = render(<Empty message={defaultMessage} />)
|
|
const placeholderCards = container.querySelectorAll('.bg-background-default-lighter')
|
|
expect(placeholderCards).toHaveLength(16)
|
|
})
|
|
|
|
it('should display the no apps found message', () => {
|
|
render(<Empty />)
|
|
expect(screen.getByText('app.filterEmpty.noApps')).toBeInTheDocument()
|
|
})
|
|
|
|
it('should display the provided message', () => {
|
|
render(<Empty message="app.newApp.noAppsFound" />)
|
|
expect(screen.getByText('app.newApp.noAppsFound')).toBeInTheDocument()
|
|
})
|
|
})
|
|
|
|
describe('Styling', () => {
|
|
it('should have correct container styling for overlay', () => {
|
|
const { container } = render(<Empty message={defaultMessage} />)
|
|
const overlay = container.querySelector('.pointer-events-none')
|
|
expect(overlay).toBeInTheDocument()
|
|
expect(overlay).toHaveClass('absolute', 'inset-0', 'z-20', 'grid', 'grid-cols-4')
|
|
})
|
|
|
|
it('should have correct styling for placeholder cards', () => {
|
|
const { container } = render(<Empty message={defaultMessage} />)
|
|
const card = container.querySelector('.bg-background-default-lighter')
|
|
expect(card).toHaveClass('rounded-xl', 'opacity-75')
|
|
})
|
|
})
|
|
|
|
describe('Edge Cases', () => {
|
|
it('should handle multiple renders without issues', () => {
|
|
const { rerender } = render(<Empty message={defaultMessage} />)
|
|
expect(screen.getByText(defaultMessage)).toBeInTheDocument()
|
|
|
|
rerender(<Empty message="app.newApp.noAppsFound" />)
|
|
expect(screen.getByText('app.newApp.noAppsFound')).toBeInTheDocument()
|
|
})
|
|
})
|
|
})
|