OpenLayers OpenLayers

Ticket #992: applyDefaults_return.patch

File applyDefaults_return.patch, 1.4 kB (added by fredj, 1 year ago)

return the 'to' object, unit tests

  • lib/OpenLayers/Util.js

    old new  
    501501            to[key] = from[key]; 
    502502        } 
    503503    } 
     504    return to; 
    504505}; 
    505506 
    506507/** 
  • tests/test_Util.html

    old new  
    136136 
    137137    function test_06_Util_applyDefaults(t) { 
    138138     
    139         t.plan(4); 
     139        t.plan(8); 
    140140         
    141141        var to = {  
    142142            'a': "abra", 
     
    154154        t.eq( to["a"], "abra", "key present in to but not from maintained"); 
    155155        t.eq( to["b"], "blorg", "key present in to and from, maintained in to"); 
    156156        t.eq( to["c"], "press", "key present in from and not to successfully copied to to"); 
     157 
     158        var ret = OpenLayers.Util.applyDefaults({'a': "abra",'b': "blorg"}, from); 
     159        t.ok( ret instanceof Object, " applyDefaults returns an object"); 
     160        t.eq( ret["a"], "abra", "key present in ret but not from maintained"); 
     161        t.eq( ret["b"], "blorg", "key present in ret and from, maintained in ret"); 
     162        t.eq( ret["c"], "press", "key present in from and not ret successfully copied to ret"); 
    157163    } 
    158164 
    159165    function test_07_Util_getParameterString(t) {