1
1
// @vitest -environment jsdom
2
-
3
2
import { describe , it , expect } from 'vitest' ;
4
3
import {
5
4
fireEvent ,
6
5
render ,
7
6
screen ,
8
7
waitFor ,
9
- within
8
+ within ,
10
9
} from '@testing-library/react' ;
11
10
12
- import BottomTabs from '../app/src/components/bottom/BottomTabs' ;
13
11
import { BrowserRouter } from 'react-router-dom' ;
12
+ import { DndProvider } from 'react-dnd' ;
13
+ import { HTML5Backend } from 'react-dnd-html5-backend' ;
14
+ import { Provider } from 'react-redux' ;
15
+ import React from 'react' ;
16
+ import BottomTabs from '../app/src/components/bottom/BottomTabs' ;
14
17
import ComponentPanel from '../app/src/components/right/ComponentPanel' ;
15
18
import ContextManager from '../app/src/components/ContextAPIManager/ContextManager' ;
16
19
import CustomizationPanel from '../app/src/containers/CustomizationPanel' ;
17
- import { DndProvider } from 'react-dnd' ;
18
20
import DragDropPanel from '../app/src/components/left/DragDropPanel' ;
19
- import { HTML5Backend } from 'react-dnd-html5-backend' ;
20
21
import HTMLPanel from '../app/src/components/left/HTMLPanel' ;
21
22
import MainContainer from '../app/src/containers/MainContainer' ;
22
- import { Provider } from 'react-redux' ;
23
- import React from 'react' ;
24
23
import StateManager from '../app/src/components/StateManagement/StateManagement' ;
25
24
import store from '../app/src/redux/store' ;
26
25
@@ -29,7 +28,7 @@ describe('Bottom Panel Render test', () => {
29
28
const { unmount } = render (
30
29
< Provider store = { store } >
31
30
< BottomTabs />
32
- </ Provider >
31
+ </ Provider > ,
33
32
) ;
34
33
expect ( screen . getAllByRole ( 'tab' ) ) . toHaveLength ( 7 ) ;
35
34
expect ( screen . getByText ( 'Component Tree' ) ) . toBeDefined ( ) ;
@@ -47,7 +46,7 @@ describe('Creation Panel', () => {
47
46
const { unmount } = render (
48
47
< Provider store = { store } >
49
48
< ComponentPanel isThemeLight = { null } />
50
- </ Provider >
49
+ </ Provider > ,
51
50
) ;
52
51
53
52
fireEvent . click ( screen . getByText ( 'Create' ) ) ;
@@ -62,20 +61,20 @@ describe('Creation Panel', () => {
62
61
const { unmount } = render (
63
62
< Provider store = { store } >
64
63
< ComponentPanel isThemeLight = { null } />
65
- </ Provider >
64
+ </ Provider > ,
66
65
) ;
67
66
68
67
fireEvent . change ( screen . getByLabelText ( 'Name' ) , {
69
68
target : {
70
- value : '!@#'
71
- }
69
+ value : '!@#' ,
70
+ } ,
72
71
} ) ;
73
72
74
73
fireEvent . click ( screen . getByText ( 'Create' ) ) ;
75
74
76
75
await waitFor ( ( ) => {
77
76
expect (
78
- screen . getByText ( 'Component name must start with a letter.' )
77
+ screen . getByText ( 'Component name must start with a letter.' ) ,
79
78
) . toBeDefined ( ) ;
80
79
} ) ;
81
80
unmount ( ) ;
@@ -87,7 +86,7 @@ describe('HTML Panel', () => {
87
86
const { unmount } = render (
88
87
< Provider store = { store } >
89
88
< HTMLPanel isThemeLight = { null } />
90
- </ Provider >
89
+ </ Provider > ,
91
90
) ;
92
91
93
92
fireEvent . click ( screen . getByText ( 'Add Element' ) ) ;
@@ -102,26 +101,26 @@ describe('HTML Panel', () => {
102
101
const { unmount } = render (
103
102
< Provider store = { store } >
104
103
< HTMLPanel isThemeLight = { null } />
105
- </ Provider >
104
+ </ Provider > ,
106
105
) ;
107
106
108
107
fireEvent . change ( screen . getByLabelText ( 'Element Name' ) , {
109
108
target : {
110
- value : '!@#'
111
- }
109
+ value : '!@#' ,
110
+ } ,
112
111
} ) ;
113
112
114
113
fireEvent . change ( screen . getByLabelText ( 'Tag' ) , {
115
114
target : {
116
- value : '!@#'
117
- }
115
+ value : '!@#' ,
116
+ } ,
118
117
} ) ;
119
118
120
119
fireEvent . click ( screen . getByText ( 'Add Element' ) ) ;
121
120
122
121
await waitFor ( ( ) => {
123
122
expect (
124
- screen . getAllByText ( '* Input must start with a letter. *' )
123
+ screen . getAllByText ( '* Input must start with a letter. *' ) ,
125
124
) . toHaveLength ( 2 ) ;
126
125
} ) ;
127
126
unmount ( ) ;
@@ -133,7 +132,7 @@ describe('Context Manager', () => {
133
132
const { unmount } = render (
134
133
< Provider store = { store } >
135
134
< ContextManager />
136
- </ Provider >
135
+ </ Provider > ,
137
136
) ;
138
137
expect ( screen . getAllByRole ( 'tab' ) ) . toHaveLength ( 3 ) ;
139
138
unmount ( ) ;
@@ -142,7 +141,7 @@ describe('Context Manager', () => {
142
141
const { unmount } = render (
143
142
< Provider store = { store } >
144
143
< ContextManager />
145
- </ Provider >
144
+ </ Provider > ,
146
145
) ;
147
146
expect ( screen . getAllByRole ( 'textbox' ) ) . toHaveLength ( 3 ) ;
148
147
expect ( screen . getAllByRole ( 'button' ) ) . toHaveLength ( 3 ) ;
@@ -154,7 +153,7 @@ describe('Context Manager', () => {
154
153
const { unmount } = render (
155
154
< Provider store = { store } >
156
155
< ContextManager />
157
- </ Provider >
156
+ </ Provider > ,
158
157
) ;
159
158
160
159
fireEvent . click ( screen . getByText ( 'Assign' ) ) ;
@@ -173,7 +172,7 @@ describe('State Manager', () => {
173
172
const { unmount } = render (
174
173
< Provider store = { store } >
175
174
< StateManager isThemeLight = { null } />
176
- </ Provider >
175
+ </ Provider > ,
177
176
) ;
178
177
expect ( screen . getAllByRole ( 'heading' ) ) . toHaveLength ( 4 ) ;
179
178
expect ( screen . getAllByRole ( 'textbox' ) ) . toHaveLength ( 2 ) ;
@@ -186,12 +185,12 @@ describe('State Manager', () => {
186
185
const { unmount } = render (
187
186
< Provider store = { store } >
188
187
< StateManager isThemeLight = { null } />
189
- </ Provider >
188
+ </ Provider > ,
190
189
) ;
191
190
fireEvent . click ( screen . getByText ( 'Display' ) ) ;
192
191
expect ( screen . getByRole ( 'table' ) ) . toBeDefined ( ) ;
193
192
expect (
194
- screen . getByText ( 'State Initialized in Current Component:' )
193
+ screen . getByText ( 'State Initialized in Current Component:' ) ,
195
194
) . toBeDefined ( ) ;
196
195
unmount ( ) ;
197
196
} ) ;
@@ -204,14 +203,14 @@ describe('Customization Panel', () => {
204
203
< BrowserRouter >
205
204
< CustomizationPanel isThemeLight = { true } />
206
205
</ BrowserRouter >
207
- </ Provider >
206
+ </ Provider > ,
208
207
) ;
209
208
expect ( screen . getByText ( 'Parent Component:' ) ) . toBeDefined ( ) ;
210
209
expect ( screen . getByText ( 'App' ) ) . toBeDefined ( ) ;
211
210
expect (
212
211
screen . getByText (
213
- 'Drag or click an html element to the canvas to see what happens!'
214
- )
212
+ 'Drag or click an html element to the canvas to see what happens!' ,
213
+ ) ,
215
214
) . toBeDefined ( ) ;
216
215
unmount ( ) ;
217
216
} ) ;
@@ -228,7 +227,7 @@ describe('Canvas', () => {
228
227
< CustomizationPanel isThemeLight = { true } />
229
228
</ DndProvider >
230
229
</ BrowserRouter >
231
- </ Provider >
230
+ </ Provider > ,
232
231
) ;
233
232
const drop = screen . getByTestId ( 'drop' ) ;
234
233
const div = screen . getAllByText ( 'Div' ) [ 0 ] ;
@@ -238,7 +237,7 @@ describe('Canvas', () => {
238
237
fireEvent . dragEnter ( drop ) ;
239
238
fireEvent . dragOver ( drop ) ;
240
239
fireEvent . drop ( drop ) ;
241
- //check if customization panel elements are rendering correctly
240
+ // check if customization panel elements are rendering correctly
242
241
const panel = screen . getAllByTestId ( 'customization' ) [ 0 ] ;
243
242
expect ( within ( panel ) . getAllByRole ( 'textbox' ) ) . toHaveLength ( 4 ) ;
244
243
// check dropdowns
0 commit comments