@@ -100,6 +100,23 @@ describe('vaadin-tooltip', () => {
100100 await nextUpdate ( tooltip ) ;
101101 expect ( overlay . hasAttribute ( 'hidden' ) ) . to . be . true ;
102102 } ) ;
103+
104+ it ( 'should fire content-changed event when text changes' , async ( ) => {
105+ const spy = sinon . spy ( ) ;
106+ tooltip . addEventListener ( 'content-changed' , spy ) ;
107+
108+ tooltip . text = 'Foo' ;
109+ await nextUpdate ( tooltip ) ;
110+ expect ( spy . calledOnce ) . to . be . true ;
111+ expect ( spy . firstCall . args [ 0 ] . detail ) . to . deep . equal ( { content : 'Foo' } ) ;
112+
113+ spy . resetHistory ( ) ;
114+
115+ tooltip . text = null ;
116+ await nextUpdate ( tooltip ) ;
117+ expect ( spy . calledOnce ) . to . be . true ;
118+ expect ( spy . firstCall . args [ 0 ] . detail ) . to . deep . equal ( { content : '' } ) ;
119+ } ) ;
103120 } ) ;
104121
105122 describe ( 'generator' , ( ) => {
@@ -150,6 +167,43 @@ describe('vaadin-tooltip', () => {
150167 await nextUpdate ( tooltip ) ;
151168 expect ( overlay . hasAttribute ( 'hidden' ) ) . to . be . true ;
152169 } ) ;
170+
171+ it ( 'should fire content-changed event when generator changes' , async ( ) => {
172+ const spy = sinon . spy ( ) ;
173+ tooltip . addEventListener ( 'content-changed' , spy ) ;
174+
175+ tooltip . generator = ( ) => 'Foo' ;
176+ await nextUpdate ( tooltip ) ;
177+ expect ( spy . calledOnce ) . to . be . true ;
178+ expect ( spy . firstCall . args [ 0 ] . detail ) . to . deep . equal ( { content : 'Foo' } ) ;
179+
180+ spy . resetHistory ( ) ;
181+
182+ tooltip . generator = ( ) => '' ;
183+ await nextUpdate ( tooltip ) ;
184+ expect ( spy . calledOnce ) . to . be . true ;
185+ expect ( spy . firstCall . args [ 0 ] . detail ) . to . deep . equal ( { content : '' } ) ;
186+ } ) ;
187+
188+ it ( 'should fire content-changed event when context changes' , async ( ) => {
189+ const spy = sinon . spy ( ) ;
190+ tooltip . addEventListener ( 'content-changed' , spy ) ;
191+
192+ tooltip . generator = ( context ) => context . text ;
193+ spy . resetHistory ( ) ;
194+
195+ tooltip . context = { text : 'Foo' } ;
196+ await nextUpdate ( tooltip ) ;
197+ expect ( spy . calledOnce ) . to . be . true ;
198+ expect ( spy . firstCall . args [ 0 ] . detail ) . to . deep . equal ( { content : 'Foo' } ) ;
199+
200+ spy . resetHistory ( ) ;
201+
202+ tooltip . context = { text : 'Bar' } ;
203+ await nextUpdate ( tooltip ) ;
204+ expect ( spy . calledOnce ) . to . be . true ;
205+ expect ( spy . firstCall . args [ 0 ] . detail ) . to . deep . equal ( { content : 'Bar' } ) ;
206+ } ) ;
153207 } ) ;
154208
155209 describe ( 'target' , ( ) => {
0 commit comments