File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -114,6 +114,7 @@ showdown.setFlavor = function (name) {
114114 if ( ! flavor . hasOwnProperty ( name ) ) {
115115 throw Error ( name + ' flavor was not found' ) ;
116116 }
117+ showdown . resetOptions ( ) ;
117118 var preset = flavor [ name ] ;
118119 setFlavor = name ;
119120 for ( var option in preset ) {
Original file line number Diff line number Diff line change @@ -130,4 +130,29 @@ describe('showdown.setFlavor()', function () {
130130 }
131131 showdown . setFlavor ( 'vanilla' ) ;
132132 } ) ;
133+
134+ it ( 'should switch between flavors correctly' , function ( ) {
135+ showdown . setFlavor ( 'github' ) ;
136+ var ghOpts = showdown . getFlavorOptions ( 'github' ) ,
137+ shOpts = showdown . getOptions ( ) ,
138+ dfOpts = showdown . getDefaultOptions ( ) ;
139+ for ( var opt in dfOpts ) {
140+ if ( ghOpts . hasOwnProperty ( opt ) ) {
141+ shOpts [ opt ] . should . equal ( ghOpts [ opt ] ) ;
142+ } else {
143+ shOpts [ opt ] . should . equal ( dfOpts [ opt ] ) ;
144+ }
145+ }
146+ showdown . setFlavor ( 'original' ) ;
147+ var orOpts = showdown . getFlavorOptions ( 'original' ) ;
148+ shOpts = showdown . getOptions ( ) ;
149+ for ( opt in dfOpts ) {
150+ if ( orOpts . hasOwnProperty ( opt ) ) {
151+ shOpts [ opt ] . should . equal ( orOpts [ opt ] ) ;
152+ } else {
153+ shOpts [ opt ] . should . equal ( dfOpts [ opt ] ) ;
154+ }
155+ }
156+ showdown . setFlavor ( 'vanilla' ) ;
157+ } ) ;
133158} ) ;
You can’t perform that action at this time.
0 commit comments