File tree 1 file changed +38
-5
lines changed
packages/kit-headless/src/components/dialog
1 file changed +38
-5
lines changed Original file line number Diff line number Diff line change @@ -4,18 +4,51 @@ import * as Dialog from './dialog';
4
4
describe ( 'Dialog' , ( ) => {
5
5
it ( 'renders an opened Dialog' , ( ) => {
6
6
mount (
7
- < Dialog . Root open = { true } >
8
- < h2 > Hello World!</ h2 >
7
+ < Dialog . Root >
8
+ < Dialog . Trigger >
9
+ < button > Open</ button >
10
+ </ Dialog . Trigger >
11
+ < Dialog . Portal >
12
+ < h2 data-test = "dialog-title" > Hello World!</ h2 >
13
+ </ Dialog . Portal >
9
14
</ Dialog . Root >
10
15
) ;
11
16
12
- cy . get ( 'dialog' ) . should ( 'contain' , 'Hello World' ) ;
17
+ cy . get ( 'button' ) . contains ( / o p e n / i) . click ( ) ;
18
+
19
+ cy . get ( '[data-test=dialog-title]' )
20
+ . should ( 'be.visible' )
21
+ . should ( 'contain' , 'Hello World' ) ;
22
+ } ) ;
23
+
24
+ it ( 'closes on backdrop-click' , ( ) => {
25
+ mount (
26
+ < Dialog . Root >
27
+ < Dialog . Trigger >
28
+ < button > Open</ button >
29
+ </ Dialog . Trigger >
30
+ < Dialog . Portal >
31
+ < h2 data-test = "dialog-title" > Hello World!</ h2 >
32
+ </ Dialog . Portal >
33
+ </ Dialog . Root >
34
+ ) ;
35
+
36
+ cy . get ( 'button' ) . contains ( / o p e n / i) . click ( ) ;
37
+
38
+ cy . get ( 'dialog' ) . click ( 'top' ) ;
39
+
40
+ cy . get ( 'dialog' ) . should ( 'not.be.visible' ) ;
13
41
} ) ;
14
42
15
43
it ( 'does not show if Dialog is closed' , ( ) => {
16
44
mount (
17
- < Dialog . Root open = { false } >
18
- < h2 > Hello World!</ h2 >
45
+ < Dialog . Root >
46
+ < Dialog . Trigger >
47
+ < button > Open</ button >
48
+ </ Dialog . Trigger >
49
+ < Dialog . Portal >
50
+ < h2 > Hello World!</ h2 >
51
+ </ Dialog . Portal >
19
52
</ Dialog . Root >
20
53
) ;
21
54
You can’t perform that action at this time.
0 commit comments