@@ -13,6 +13,7 @@ governing permissions and limitations under the License.
13
13
import '../' ;
14
14
import { SideNavItem } from '../' ;
15
15
import { fixture , elementUpdated , html , expect } from '@open-wc/testing' ;
16
+ import { getByText , queryByText } from 'testing-library__dom' ;
16
17
17
18
describe ( 'Sidenav Item' , ( ) => {
18
19
it ( 'can exist disabled and with no parent' , async ( ) => {
@@ -68,24 +69,30 @@ describe('Sidenav Item', () => {
68
69
69
70
await elementUpdated ( el ) ;
70
71
71
- expect ( el . shadowRoot ) . to . exist ;
72
- if ( ! el . shadowRoot ) return ;
73
-
74
- let slot = el . shadowRoot . querySelector ( 'slot' ) ;
75
- expect ( slot ) . not . to . exist ;
72
+ let section1 = queryByText ( el , 'Section 1' ) ;
73
+ let section2 = queryByText ( el , 'Section 2' ) ;
76
74
77
75
expect ( el . expanded ) . to . be . false ;
76
+ expect ( section1 , 'section 1: closed initial' ) . to . be . null ;
77
+ expect ( section2 , 'section 2: closed initial' ) . to . be . null ;
78
78
79
79
el . click ( ) ;
80
-
81
80
await elementUpdated ( el ) ;
82
81
83
82
expect ( el . expanded ) . to . be . true ;
83
+ section1 = getByText ( el , 'Section 1' ) ;
84
+ section2 = getByText ( el , 'Section 2' ) ;
85
+ expect ( section1 , 'section 1: opened' ) . to . not . be . null ;
86
+ expect ( section2 , 'section 2: opened' ) . to . not . be . null ;
87
+
88
+ el . click ( ) ;
89
+ await elementUpdated ( el ) ;
84
90
85
- slot = el . shadowRoot . querySelector ( 'slot' ) ;
86
- expect ( slot ) . to . exist ;
87
- if ( ! slot ) return ;
91
+ section1 = queryByText ( el , 'Section 1' ) ;
92
+ section2 = queryByText ( el , 'Section 2' ) ;
88
93
89
- expect ( slot . assignedElements ( ) . length ) . to . equal ( 2 ) ;
94
+ expect ( el . expanded ) . to . be . false ;
95
+ expect ( section1 , 'section 1: closed' ) . to . be . null ;
96
+ expect ( section2 , 'section 2: closed' ) . to . be . null ;
90
97
} ) ;
91
98
} ) ;
0 commit comments