File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,10 @@ const DropdownMenu = (props, context) => {
2424 const classes = mapToCssModules ( classNames (
2525 className ,
2626 'dropdown-menu' ,
27- { 'dropdown-menu-right' : right }
27+ {
28+ 'dropdown-menu-right' : right ,
29+ show : context . isOpen ,
30+ }
2831 ) , cssModule ) ;
2932
3033 return (
Original file line number Diff line number Diff line change @@ -62,7 +62,6 @@ class DropdownToggle extends React.Component {
6262 {
6363 'dropdown-toggle' : caret || split ,
6464 'dropdown-toggle-split' : split ,
65- active : this . context . isOpen ,
6665 'nav-link' : nav
6766 }
6867 ) , cssModule ) ;
Original file line number Diff line number Diff line change @@ -26,6 +26,40 @@ describe('DropdownMenu', () => {
2626 expect ( wrapper . find ( '.dropdown-menu' ) . length ) . toBe ( 1 ) ;
2727 } ) ;
2828
29+ it ( 'should not have the class "show" when isOpen context is false' , ( ) => {
30+ isOpen = false ;
31+ const wrapper = mount (
32+ < DropdownMenu >
33+ < p > Content</ p >
34+ </ DropdownMenu > ,
35+ {
36+ context : {
37+ isOpen : isOpen
38+ }
39+ }
40+ ) ;
41+
42+ expect ( wrapper . find ( '.dropdown-menu' ) . hasClass ( 'show' ) ) . toBe ( false ) ;
43+ expect ( wrapper . find ( '.show' ) . length ) . toBe ( 0 ) ;
44+ } ) ;
45+
46+ it ( 'should have the class "show" when isOpen context is true' , ( ) => {
47+ isOpen = true ;
48+ const wrapper = mount (
49+ < DropdownMenu >
50+ < p > Content</ p >
51+ </ DropdownMenu > ,
52+ {
53+ context : {
54+ isOpen : isOpen
55+ }
56+ }
57+ ) ;
58+
59+ expect ( wrapper . find ( '.dropdown-menu' ) . hasClass ( 'show' ) ) . toBe ( true ) ;
60+ expect ( wrapper . find ( '.show' ) . length ) . toBe ( 1 ) ;
61+ } ) ;
62+
2963 it ( 'should render right aligned menus' , ( ) => {
3064 isOpen = true ;
3165 const wrapper = mount (
You can’t perform that action at this time.
0 commit comments