@@ -87,6 +87,34 @@ describe('Events', function() {
87
87
} ) ;
88
88
} ) ;
89
89
90
+ describe ( 'optgroup_add' , function ( ) {
91
+ beforeEach ( function ( ) {
92
+ test = setup_test ( '<select><option value="a" selected></option><option value="b" selected></option><option value="c"></option></select>' , { } ) ;
93
+ } ) ;
94
+ afterEach ( function ( ) {
95
+ test . teardown ( ) ;
96
+ } ) ;
97
+ it ( 'should be triggered' , function ( done ) {
98
+ test . selectize . on ( 'optgroup_add' , function ( ) { done ( ) ; } ) ;
99
+ test . selectize . addOptionGroup ( 'id' , { label : 'Group' } ) ;
100
+ } ) ;
101
+ it ( 'should contain optgroup id' , function ( done ) {
102
+ test . selectize . on ( 'optgroup_add' , function ( id , data ) {
103
+ expect ( id ) . to . be . equal ( 'id' ) ;
104
+ done ( ) ;
105
+ } ) ;
106
+ test . selectize . addOptionGroup ( 'id' , { label : 'Group' } ) ;
107
+ } ) ;
108
+ it ( 'should contain outgroup data' , function ( done ) {
109
+ var optgroup = { label : 'Group' } ;
110
+ test . selectize . on ( 'optgroup_add' , function ( id , data ) {
111
+ expect ( data ) . to . eql ( optgroup ) ;
112
+ done ( ) ;
113
+ } ) ;
114
+ test . selectize . addOptionGroup ( 'id' , optgroup ) ;
115
+ } ) ;
116
+ } ) ;
117
+
90
118
describe ( 'option_add' , function ( ) {
91
119
beforeEach ( function ( ) {
92
120
test = setup_test ( '<select><option value="a" selected></option><option value="b" selected></option><option value="c"></option></select>' , { } ) ;
@@ -110,7 +138,7 @@ describe('Events', function() {
110
138
it ( 'should contain option data' , function ( done ) {
111
139
var option = { value : 'e' } ;
112
140
test . selectize . on ( 'option_add' , function ( value , data ) {
113
- expect ( data ) . to . be . equal ( data ) ;
141
+ expect ( option ) . to . eql ( data ) ;
114
142
done ( ) ;
115
143
} ) ;
116
144
test . selectize . addOption ( option ) ;
0 commit comments