|
| 1 | +import React from 'react'; |
| 2 | +import { render, screen, fireEvent } from '../src/test-utils.js'; |
| 3 | +import '@testing-library/jest-dom/extend-expect'; |
| 4 | +// import DnD from '../src/components/DnD'; |
| 5 | +import CompCreator from '../src/components/CompCreator'; |
| 6 | +import Tree from '../src/components/Tree'; |
| 7 | +// import TreeRecursive from '../src/components/TreeRecursive'; |
| 8 | +import TreeFile from '../src/components/TreeFile'; |
| 9 | + |
| 10 | +describe('Left Panel', () => { |
| 11 | + test('renders CompCreator component with input field and add button', () => { |
| 12 | + const { getByTestId } = render(<CompCreator />); |
| 13 | + expect(screen.getByText('React Component')).toBeInTheDocument(); |
| 14 | + expect(screen.getByRole('textbox')).toBeInTheDocument(); |
| 15 | + const addButton = getByTestId('add-button'); |
| 16 | + expect(addButton).toBeInTheDocument(); |
| 17 | + // const mockFunction = jest.fn(() => true); |
| 18 | + // fireEvent.click(addButton); |
| 19 | + // expect(mockFunction()).toBe(true); |
| 20 | + }); |
| 21 | + |
| 22 | + test('value of comp creator input field changes', () => { |
| 23 | + const { queryByPlaceholderText } = render(<CompCreator />); |
| 24 | + const input = queryByPlaceholderText('Component Name'); |
| 25 | + fireEvent.change(input, { target: { value: 'test' } }); |
| 26 | + expect(input.value).toBe('test'); |
| 27 | + }); |
| 28 | + |
| 29 | + test('renders the tree component which displays file tree', () => { |
| 30 | + const { getByTestId } = render(<Tree />); |
| 31 | + expect(getByTestId('filetree')).toBeInTheDocument(); |
| 32 | + }); |
| 33 | + |
| 34 | + // test('renders the tree folders with on click functionality', () => { |
| 35 | + // const { getByTestId } = render(<TreeRecursive />); |
| 36 | + // expect(getByTestId('folder')).toBeInTheDocument(); |
| 37 | + // }); |
| 38 | + |
| 39 | + // test('renders the tree files with on click functionality', () => { |
| 40 | + // const { getByTestId } = render(<TreeFile />); |
| 41 | + // expect(getByTestId('file')).toBeInTheDocument(); |
| 42 | + // }); |
| 43 | + |
| 44 | + //HAVING ISSUES WITH TESTS INVOLVING DND DUE TO PROVIDER/STORE ISSUE WITH REACT TESTING LIBRARY |
| 45 | + |
| 46 | + // test('renders fflow logo with on click functionality', () => { |
| 47 | + // const { getByTestId } = render(<DnD />); |
| 48 | + // const appLogo = getByTestId('app-logo'); |
| 49 | + // expect(appLogo).toBeInTheDocument(); |
| 50 | + // const mockFunction = jest.fn(() => true); |
| 51 | + // fireEvent.click(appLogo); |
| 52 | + // expect(mockFunction()).toBe(true); |
| 53 | + // }); |
| 54 | + |
| 55 | + // test('renders tree component', () => { |
| 56 | + // render(<DnD />); |
| 57 | + // expect(screen.getByText('FOLDERS')).toBeInTheDocument(); |
| 58 | + // }); |
| 59 | +}); |
0 commit comments