File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed
packages/compass-components/src/components Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ import React , { useState } from 'react' ;
2+ import { render , screen , waitFor } from '@mongodb-js/testing-library-compass' ;
3+ import {
4+ DrawerContentProvider ,
5+ DrawerSection ,
6+ DrawerAnchor ,
7+ } from './drawer-portal' ;
8+ import { expect } from 'chai' ;
9+
10+ describe ( 'DrawerSection' , function ( ) {
11+ it ( 'renders DrawerSection in the portal and updates the content when it updates' , async function ( ) {
12+ let setCount ;
13+
14+ function TestDrawer ( ) {
15+ const [ count , _setCount ] = useState ( 0 ) ;
16+ setCount = _setCount ;
17+ return (
18+ < DrawerContentProvider >
19+ < DrawerAnchor >
20+ < DrawerSection
21+ id = "test-section"
22+ label = "Test section"
23+ title = { `Test section: ${ count } ` }
24+ glyph = "Trash"
25+ autoOpen
26+ >
27+ This is a test section and the count is { count }
28+ </ DrawerSection >
29+ </ DrawerAnchor >
30+ </ DrawerContentProvider >
31+ ) ;
32+ }
33+
34+ render ( < TestDrawer > </ TestDrawer > ) ;
35+
36+ await waitFor ( ( ) => {
37+ expect ( screen . getByText ( 'Test section: 0' ) ) . to . be . visible ;
38+ expect ( screen . getByText ( 'This is a test section and the count is 0' ) ) . to
39+ . be . visible ;
40+ } ) ;
41+
42+ setCount ( 42 ) ;
43+
44+ await waitFor ( ( ) => {
45+ expect ( screen . getByText ( 'Test section: 42' ) ) . to . be . visible ;
46+ expect ( screen . getByText ( 'This is a test section and the count is 42' ) ) . to
47+ . be . visible ;
48+ } ) ;
49+ } ) ;
50+ } ) ;
You can’t perform that action at this time.
0 commit comments