/**
* ProductListDialog (components/ProductListDialog.tsx) — a read-only bottom
* dialog listing the products passed in as props.
*/
import React from 'react'
import { screen } from '@testing-library/react-native'
import { ProductListDialog } from '@/components/ProductListDialog'
import { renderWithProviders } from '../helpers/render'
const products = [
{ id: 1, name: 'Chicken' },
{ id: 2, name: 'Mutton' },
{ id: 3, name: 'Fish' },
]
describe('ProductListDialog', () => {
it('renders the product count and each product when open', () => {
renderWithProviders(
)
expect(screen.getByText('Products (3)')).toBeVisible()
expect(screen.getByText('Chicken')).toBeVisible()
expect(screen.getByText('Mutton')).toBeVisible()
expect(screen.getByText('Fish')).toBeVisible()
})
it('shows a count of zero for an empty list', () => {
renderWithProviders(
)
expect(screen.getByText('Products (0)')).toBeVisible()
})
it('hides its content while closed', () => {
renderWithProviders(
)
// A closed Modal does not mount its children in the tree.
expect(screen.queryByText('Products (3)')).toBeNull()
})
})