|
| 1 | +import React from 'react'; |
| 2 | +import { render, screen } from '@testing-library/react'; |
| 3 | +import '@testing-library/jest-dom'; |
| 4 | +import { Callstack } from '@/app/(main)/sections/callstack'; |
| 5 | + |
| 6 | +jest.mock('@/store/store', () => ({ |
| 7 | + useQueueManagerStore: jest |
| 8 | + .fn() |
| 9 | + .mockImplementation(() => ['stack-1', 'stack-2']), |
| 10 | +})); |
| 11 | + |
| 12 | +describe('Callstack Component', () => { |
| 13 | + beforeEach(() => render(<Callstack />)); |
| 14 | + |
| 15 | + it('should render the callstack title', () => { |
| 16 | + const titleElement = screen.getByText(/Callstack/i); |
| 17 | + expect(titleElement).toBeInTheDocument(); |
| 18 | + }); |
| 19 | + |
| 20 | + it('should render callstacks', () => { |
| 21 | + const callstack1 = screen.getByText(/stack-1/i); |
| 22 | + const callstack2 = screen.getByText(/stack-2/i); |
| 23 | + expect(callstack1).toBeInTheDocument(); |
| 24 | + expect(callstack2).toBeInTheDocument(); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should not render the modal by default', async () => { |
| 28 | + const descriptionElements = screen.queryAllByText( |
| 29 | + /A call stack is a mechanism for an interpreter to keep track of its place/i |
| 30 | + ); |
| 31 | + expect(descriptionElements.length).toBe(0); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should render the modal after icon click', async () => { |
| 35 | + const modalButton = screen.getByRole('button'); |
| 36 | + await modalButton.click(); |
| 37 | + const descriptionElement = screen.getByText( |
| 38 | + /A call stack is a mechanism for an interpreter to keep track of its place/i |
| 39 | + ); |
| 40 | + expect(descriptionElement).toBeInTheDocument(); |
| 41 | + }); |
| 42 | +}); |
0 commit comments