@@ -3,44 +3,49 @@ import '@testing-library/jest-dom';
3
3
import { DndProvider } from 'react-dnd' ;
4
4
import { HTML5Backend } from 'react-dnd-html5-backend' ;
5
5
import { render , fireEvent , cleanup , screen } from '@testing-library/react' ;
6
- // import StateContext from '../app/src/context/context';
7
- // import initialState from '../app/src/context/initialState';
8
- // import reducer from '../app/src/reducers/componentReducer';
9
- import HTMLPanel from '../app/src/components/left/HTMLPanel' ;
6
+ import DragDropPanel from '../app/src/components/left/DragDropPanel' ;
7
+ import { initialState } from '../app/src/redux/reducers/slice/appStateSlice' ;
8
+ import { Provider } from 'react-redux' ;
9
+ import store from '../app/src/redux/store' ;
10
+
10
11
function Test ( ) {
11
- const [ state , dispatch ] = useReducer ( reducer , initialState ) ;
12
12
return (
13
- < DndProvider backend = { HTML5Backend } >
14
- { /* <StateContext.Provider value={[state, dispatch]}> */ }
15
- < HTMLPanel />
16
- { /* </StateContext.Provider> */ }
17
- </ DndProvider >
13
+ < Provider store = { store } >
14
+ < DndProvider backend = { HTML5Backend } >
15
+ < DragDropPanel />
16
+ </ DndProvider >
17
+ </ Provider >
18
18
) ;
19
19
}
20
- xtest ( 'Renders HTMLPanel component properly' , ( ) => {
20
+ test ( 'Renders HTMLPanel component properly' , ( ) => {
21
21
render ( < Test /> ) ;
22
- expect ( screen . getAllByRole ( 'textbox' ) ) . toHaveLength ( 2 ) ;
22
+ // expect(screen.getAllByRole('textbox')).toHaveLength(2);
23
23
expect ( screen . getByText ( 'Div' ) ) . toBeInTheDocument ( ) ;
24
- expect ( screen . getByText ( 'Image ' ) ) . toBeInTheDocument ( ) ;
24
+ expect ( screen . getByText ( 'Img ' ) ) . toBeInTheDocument ( ) ;
25
25
expect ( screen . getByText ( 'Form' ) ) . toBeInTheDocument ( ) ;
26
- expect ( screen . getByText ( 'List' ) ) . toBeInTheDocument ( ) ;
27
26
expect ( screen . getByText ( 'Button' ) ) . toBeInTheDocument ( ) ;
28
27
expect ( screen . getByText ( 'Link' ) ) . toBeInTheDocument ( ) ;
29
28
expect ( screen . getByText ( 'Paragraph' ) ) . toBeInTheDocument ( ) ;
30
29
expect ( screen . getByText ( 'Header 1' ) ) . toBeInTheDocument ( ) ;
31
30
expect ( screen . getByText ( 'Header 2' ) ) . toBeInTheDocument ( ) ;
32
31
expect ( screen . getByText ( 'Span' ) ) . toBeInTheDocument ( ) ;
32
+ expect ( screen . getByText ( 'Input' ) ) . toBeInTheDocument ( ) ;
33
+ expect ( screen . getByText ( 'Label' ) ) . toBeInTheDocument ( ) ;
34
+ expect ( screen . getByText ( 'Ordered List' ) ) . toBeInTheDocument ( ) ;
35
+ expect ( screen . getByText ( 'Unordered List' ) ) . toBeInTheDocument ( ) ;
36
+ expect ( screen . getByText ( 'Menu' ) ) . toBeInTheDocument ( ) ;
37
+ expect ( screen . getByText ( 'List' ) ) . toBeInTheDocument ( ) ;
33
38
expect ( screen . queryByText ( 'separator' ) ) . toBe ( null ) ;
34
39
} ) ;
35
40
36
- xtest ( 'Adds new custom element' , ( ) => {
37
- render ( < Test /> ) ;
38
- fireEvent . change ( screen . getAllByRole ( 'textbox' ) [ 0 ] , {
39
- target : { value : 'Testing' }
40
- } ) ;
41
- fireEvent . change ( screen . getAllByRole ( 'textbox' ) [ 1 ] , {
42
- target : { value : 'Testing' }
43
- } ) ;
44
- fireEvent . click ( screen . getByDisplayValue ( 'Add Element' ) ) ;
45
- expect ( screen . getByText ( 'Testing' ) ) . toBeInTheDocument ( ) ;
46
- } ) ;
41
+ // test ('Adds new custom element', () => {
42
+ // render(<Test />);
43
+ // fireEvent.change(screen.getAllByRole('textbox')[0], {
44
+ // target: { value: 'Testing' }
45
+ // });
46
+ // fireEvent.change(screen.getAllByRole('textbox')[1], {
47
+ // target: { value: 'Testing' }
48
+ // });
49
+ // fireEvent.click(screen.getByDisplayValue('Add Element'));
50
+ // expect(screen.getByText('Testing')).toBeInTheDocument();
51
+ // });
0 commit comments