@@ -83,6 +83,45 @@ describe('eventable', function () {
8383 this . obj . notify ( 'publish' , 'success' )
8484 expect ( called ) . toEqual ( 1 )
8585 } )
86+
87+ it ( 'accepts multiple whitespace separated event names' , function ( ) {
88+ let called = 0
89+ this . obj . on ( 'publish unpublish' , ( ) => {
90+ called ++
91+ } )
92+
93+ this . obj . notify ( 'publish' )
94+ this . obj . notify ( 'unpublish' )
95+ this . obj . notify ( 'foo' ) // should do nothing
96+ expect ( called ) . toEqual ( 2 )
97+ } )
98+
99+ it ( 'accepts an object to register multiple events' , function ( ) {
100+ let published = 0
101+ let unpublished = 0
102+
103+ this . obj . on ( {
104+ publish : ( ) => { published ++ } ,
105+ unpublish : ( ) => { unpublished ++ }
106+ } )
107+
108+ this . obj . notify ( 'publish' )
109+ this . obj . notify ( 'unpublish' )
110+ expect ( published ) . toEqual ( 1 )
111+ expect ( unpublished ) . toEqual ( 1 )
112+ } )
113+
114+ it ( 'accepts multiple event names in object form' , function ( ) {
115+ let called = 0
116+
117+ this . obj . on ( {
118+ 'publish unpublish' : ( ) => { called ++ }
119+ } )
120+
121+ this . obj . notify ( 'publish' )
122+ this . obj . notify ( 'unpublish' )
123+ expect ( called ) . toEqual ( 2 )
124+ } )
86125 } )
87126
88127 describe ( 'off()' , function ( ) {
0 commit comments