This repository was archived by the owner on Apr 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-5
lines changed
Expand file tree Collapse file tree 2 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -254,13 +254,13 @@ Debuglet.prototype.updateActiveBreakpoints_ = function(breakpoints) {
254254 } ) ;
255255
256256 // Remove completed breakpoints that the server no longer cares about.
257- mapSubtract ( this . completedBreakpointMap_ , updatedBreakpointMap )
257+ Debuglet . mapSubtract ( this . completedBreakpointMap_ , updatedBreakpointMap )
258258 . forEach ( function ( breakpoint ) {
259259 delete this . completedBreakpointMap_ [ breakpoint . id ] ;
260260 } , this ) ;
261261
262262 // Remove active breakpoints that the server no longer care about.
263- mapSubtract ( this . activeBreakpointMap_ , updatedBreakpointMap )
263+ Debuglet . mapSubtract ( this . activeBreakpointMap_ , updatedBreakpointMap )
264264 . forEach ( this . removeBreakpoint_ , this ) ;
265265} ;
266266
@@ -396,17 +396,16 @@ Debuglet.prototype.stop = function() {
396396
397397/**
398398 * Performs a set subtract. Returns A - B given maps A, B.
399- * TODO(ofrobots): we need unit tests for this
400399 * @return {Array.<Breakpoint> } A array containing elements from A that are not
401400 * in B.
402401 */
403- function mapSubtract ( A , B ) {
402+ Debuglet . mapSubtract = function mapSubtract ( A , B ) {
404403 var removed = [ ] ;
405404 for ( var key in A ) {
406405 if ( ! B [ key ] ) {
407406 removed . push ( A [ key ] ) ;
408407 }
409408 }
410409 return removed ;
411- }
410+ } ;
412411
Original file line number Diff line number Diff line change @@ -247,5 +247,16 @@ describe(__filename, function(){
247247
248248 debuglet . start ( ) ;
249249 } ) ;
250+
251+ describe ( 'map subtract' , function ( ) {
252+ it ( 'should be correct' , function ( ) {
253+ var a = { a : 1 , b : 2 } ;
254+ var b = { a : 1 } ;
255+ assert . deepEqual ( Debuglet . mapSubtract ( a , b ) , [ 2 ] ) ;
256+ assert . deepEqual ( Debuglet . mapSubtract ( b , a ) , [ ] ) ;
257+ assert . deepEqual ( Debuglet . mapSubtract ( a , { } ) , [ 1 , 2 ] ) ;
258+ assert . deepEqual ( Debuglet . mapSubtract ( { } , b ) , [ ] ) ;
259+ } ) ;
260+ } ) ;
250261} ) ;
251262
You can’t perform that action at this time.
0 commit comments