@@ -14,6 +14,7 @@ import '../sp-sidenav.js';
14
14
import '../sp-sidenav-item.js' ;
15
15
import { SideNavItem } from '../' ;
16
16
import { fixture , elementUpdated , html , expect } from '@open-wc/testing' ;
17
+ import { getByText , queryByText } from 'testing-library__dom' ;
17
18
18
19
describe ( 'Sidenav Item' , ( ) => {
19
20
it ( 'can exist disabled and with no parent' , async ( ) => {
@@ -69,29 +70,31 @@ describe('Sidenav Item', () => {
69
70
70
71
await elementUpdated ( el ) ;
71
72
72
- expect ( el . shadowRoot ) . to . exist ;
73
- if ( ! el . shadowRoot ) return ;
74
-
75
- let slot : HTMLSlotElement | null = el . shadowRoot . querySelector (
76
- 'slot:not([name])'
77
- ) ;
78
- expect ( slot ) . not . to . exist ;
73
+ let section1 = queryByText ( el , 'Section 1' ) ;
74
+ let section2 = queryByText ( el , 'Section 2' ) ;
79
75
80
76
expect ( el . expanded ) . to . be . false ;
77
+ expect ( section1 , 'section 1: closed initial' ) . to . be . null ;
78
+ expect ( section2 , 'section 2: closed initial' ) . to . be . null ;
81
79
82
80
el . click ( ) ;
83
-
84
81
await elementUpdated ( el ) ;
85
82
86
83
expect ( el . expanded ) . to . be . true ;
84
+ section1 = getByText ( el , 'Section 1' ) ;
85
+ section2 = getByText ( el , 'Section 2' ) ;
86
+ expect ( section1 , 'section 1: opened' ) . to . not . be . null ;
87
+ expect ( section2 , 'section 2: opened' ) . to . not . be . null ;
87
88
88
- slot = el . shadowRoot . querySelector (
89
- 'slot:not([name])'
90
- ) as HTMLSlotElement ;
91
- expect ( slot ) . to . exist ;
92
- if ( ! slot ) return ;
89
+ el . click ( ) ;
90
+ await elementUpdated ( el ) ;
91
+
92
+ section1 = queryByText ( el , 'Section 1' ) ;
93
+ section2 = queryByText ( el , 'Section 2' ) ;
93
94
94
- expect ( slot . assignedElements ( ) . length ) . to . equal ( 2 ) ;
95
+ expect ( el . expanded ) . to . be . false ;
96
+ expect ( section1 , 'section 1: closed' ) . to . be . null ;
97
+ expect ( section2 , 'section 2: closed' ) . to . be . null ;
95
98
} ) ;
96
99
97
100
it ( 'populated `aria-current`' , async ( ) => {
0 commit comments