@@ -13,6 +13,10 @@ 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 {
17
+ getByText ,
18
+ queryByText ,
19
+ } from '@bundled-es-modules/testing-library-dom' ;
16
20
17
21
describe ( 'Sidenav Item' , ( ) => {
18
22
it ( 'can exist disabled and with no parent' , async ( ) => {
@@ -68,24 +72,30 @@ describe('Sidenav Item', () => {
68
72
69
73
await elementUpdated ( el ) ;
70
74
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 ;
75
+ let section1 = queryByText ( el , 'Section 1' ) ;
76
+ let section2 = queryByText ( el , 'Section 2' ) ;
76
77
77
78
expect ( el . expanded ) . to . be . false ;
79
+ expect ( section1 , 'section 1: closed initial' ) . to . be . null ;
80
+ expect ( section2 , 'section 2: closed initial' ) . to . be . null ;
78
81
79
82
el . click ( ) ;
80
-
81
83
await elementUpdated ( el ) ;
82
84
83
85
expect ( el . expanded ) . to . be . true ;
86
+ section1 = getByText ( el , 'Section 1' ) ;
87
+ section2 = getByText ( el , 'Section 2' ) ;
88
+ expect ( section1 , 'section 1: opened' ) . to . not . be . null ;
89
+ expect ( section2 , 'section 2: opened' ) . to . not . be . null ;
90
+
91
+ el . click ( ) ;
92
+ await elementUpdated ( el ) ;
84
93
85
- slot = el . shadowRoot . querySelector ( 'slot' ) ;
86
- expect ( slot ) . to . exist ;
87
- if ( ! slot ) return ;
94
+ section1 = queryByText ( el , 'Section 1' ) ;
95
+ section2 = queryByText ( el , 'Section 2' ) ;
88
96
89
- expect ( slot . assignedElements ( ) . length ) . to . equal ( 2 ) ;
97
+ expect ( el . expanded ) . to . be . false ;
98
+ expect ( section1 , 'section 1: closed' ) . to . be . null ;
99
+ expect ( section2 , 'section 2: closed' ) . to . be . null ;
90
100
} ) ;
91
101
} ) ;
0 commit comments