@@ -13,6 +13,7 @@ governing permissions and limitations under the License.
13
13
import '../sp-sidenav-item.js' ;
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,29 +69,31 @@ 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 : HTMLSlotElement | null = el . shadowRoot . querySelector (
75
- 'slot:not([name])'
76
- ) ;
77
- expect ( slot ) . not . to . exist ;
72
+ let section1 = queryByText ( el , 'Section 1' ) ;
73
+ let section2 = queryByText ( el , 'Section 2' ) ;
78
74
79
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 ;
80
78
81
79
el . click ( ) ;
82
-
83
80
await elementUpdated ( el ) ;
84
81
85
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 ;
86
87
87
- slot = el . shadowRoot . querySelector (
88
- 'slot:not([name])'
89
- ) as HTMLSlotElement ;
90
- expect ( slot ) . to . exist ;
91
- if ( ! slot ) return ;
88
+ el . click ( ) ;
89
+ await elementUpdated ( el ) ;
90
+
91
+ section1 = queryByText ( el , 'Section 1' ) ;
92
+ section2 = queryByText ( el , 'Section 2' ) ;
92
93
93
- 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 ;
94
97
} ) ;
95
98
96
99
it ( 'populated `aria-current`' , async ( ) => {
0 commit comments