@@ -213,6 +213,15 @@ describe('Scope', () => {
213213 intArray : { value : [ 1 , 2 , 3 ] , type : 'integer[]' , unit : 'ms' } ,
214214 } ) ;
215215 } ) ;
216+
217+ it ( 'notifies scope listeners once per call' , ( ) => {
218+ const scope = new Scope ( ) ;
219+ const listener = vi . fn ( ) ;
220+ scope . addScopeListener ( listener ) ;
221+ scope . setAttribute ( 'str' , 'b' ) ;
222+ scope . setAttribute ( 'int' , 1 ) ;
223+ expect ( listener ) . toHaveBeenCalledTimes ( 2 ) ;
224+ } ) ;
216225 } ) ;
217226
218227 describe ( 'setAttributes' , ( ) => {
@@ -268,6 +277,42 @@ describe('Scope', () => {
268277 intArray : { type : 'integer[]' , value : [ 1 , 2 , 3 ] , unit : 'ms' } ,
269278 } ) ;
270279 } ) ;
280+
281+ it ( 'notifies scope listeners once per call' , ( ) => {
282+ const scope = new Scope ( ) ;
283+ const listener = vi . fn ( ) ;
284+ scope . addScopeListener ( listener ) ;
285+ scope . setAttributes ( { str : 'b' , int : 1 } ) ;
286+ scope . setAttributes ( { bool : true } ) ;
287+ expect ( listener ) . toHaveBeenCalledTimes ( 2 ) ;
288+ } ) ;
289+ } ) ;
290+
291+ describe ( 'removeAttribute' , ( ) => {
292+ it ( 'removes an attribute' , ( ) => {
293+ const scope = new Scope ( ) ;
294+ scope . setAttribute ( 'str' , 'b' ) ;
295+ scope . setAttribute ( 'int' , 1 ) ;
296+ scope . removeAttribute ( 'str' ) ;
297+ expect ( scope [ '_attributes' ] ) . toEqual ( { int : { type : 'integer' , value : 1 } } ) ;
298+ } ) ;
299+
300+ it ( 'notifies scope listeners after deletion' , ( ) => {
301+ const scope = new Scope ( ) ;
302+ const listener = vi . fn ( ) ;
303+ scope . addScopeListener ( listener ) ;
304+ } ) ;
305+
306+ it ( 'does nothing if the attribute does not exist' , ( ) => {
307+ const scope = new Scope ( ) ;
308+ const listener = vi . fn ( ) ;
309+
310+ scope . addScopeListener ( listener ) ;
311+ scope . removeAttribute ( 'str' ) ;
312+
313+ expect ( scope [ '_attributes' ] ) . toEqual ( { } ) ;
314+ expect ( listener ) . not . toHaveBeenCalled ( ) ;
315+ } ) ;
271316 } ) ;
272317
273318 test ( 'setUser' , ( ) => {
0 commit comments