Changeset 1896 for trunk


Ignore:
Timestamp:
2011-04-19 11:48:54 (13 months ago)
Author:
mpo
Message:

upgrade for qunit

Note the important changes to the test api:

  • equals deprecated for equal,
  • isSet removed (change to deepEqual or own sameJq)


Also note: equal() fails on object-graphs with circular dependencies (which kauri forms happens to have for all controls -> form, and form being a control will have form -> form)

Location:
trunk/modules
Files:
3 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/crosscheck/tests.js

    r1191 r1896  
    1111    crosscheck.addPath('../../kauri-jquery/src/test/qunit/');                         
    1212    crosscheck.addPath('../../kauri-jquery/src/test/kauri.util/');                         
    13     crosscheck.addPath('../../kauri-jquery/src/main/kauri/static/jquery/jquery-1.3.2/');                         
    14     crosscheck.addPath('../../kauri-jquery/src/main/kauri/static/jquery.ui/jquery.ui-1.7.1/js/'); 
     13    crosscheck.addPath('../../kauri-jquery/src/main/kauri/static/jquery/jquery-1.5.2/');                         
     14    crosscheck.addPath('../../kauri-jquery/src/main/kauri/static/jquery.ui/jquery.ui-1.8.11/js/'); 
    1515    crosscheck.addPath('../../kauri-jquery/src/main/kauri/static-{build}.key/kauri.util/'); 
    1616 
     
    2020    crosscheck.addPath('../kauri-jquery/src/test/qunit/');                         
    2121    crosscheck.addPath('../kauri-jquery/src/test/kauri.util/');                         
    22     crosscheck.addPath('../kauri-jquery/src/main/kauri/static/jquery/jquery-1.3.2/');                         
    23     crosscheck.addPath('../kauri-jquery/src/main/kauri/static/jquery.ui/jquery.ui-1.7.1/js/'); 
     22    crosscheck.addPath('../kauri-jquery/src/main/kauri/static/jquery/jquery-1.5.2/');                         
     23    crosscheck.addPath('../kauri-jquery/src/main/kauri/static/jquery.ui/jquery.ui-1.8.11/js/'); 
    2424    crosscheck.addPath('../kauri-jquery/src/main/kauri/static-{build}.key/kauri.util/'); 
    2525 
     
    2929    crosscheck.addPath('modules/kauri-jquery/src/test/qunit/');                         
    3030    crosscheck.addPath('modules/kauri-jquery/src/test/kauri.util/');                         
    31     crosscheck.addPath('modules/kauri-jquery/src/main/kauri/static/jquery/jquery-1.3.2/');                         
    32     crosscheck.addPath('modules/kauri-jquery/src/main/kauri/static/jquery.ui/jquery.ui-1.7.1/js/'); 
     31    crosscheck.addPath('modules/kauri-jquery/src/main/kauri/static/jquery/jquery-1.5.2/');                         
     32    crosscheck.addPath('modules/kauri-jquery/src/main/kauri/static/jquery.ui/jquery.ui-1.8.11/js/'); 
    3333    crosscheck.addPath('modules/kauri-jquery/src/main/kauri/static-{build}.key/kauri.util/'); 
    3434 
    35     crosscheck.load('jquery-1.3.2.js'); 
    36     crosscheck.load('jquery-ui-1.7.1.min.js'); 
    37     crosscheck.load('testrunner.js'); 
     35    crosscheck.load('jquery-1.5.2.js'); 
     36    crosscheck.load('jquery-ui-1.8.11.min.js'); 
     37    crosscheck.load('qunit.js'); 
    3838 
    3939    crosscheck.load('core.js'); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-basic-controls.js

    r1874 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Basic Control Testing'); 
    2  
    3 var kf = $.org.kauriproject.forms; 
    4  
    54 
    65test("form element indexing", function() { 
     
    4342}); 
    4443 
    45  
    4644function indexElements( space, form) { 
    4745 
     
    6159        var index = $this.attr('kauri-index'); 
    6260        var assertIndex = $this.attr('assert-index'); 
    63         equals(index, assertIndex, "checked attribute addition"); 
     61        equal(index, assertIndex, "checked attribute addition"); 
    6462    }); 
    6563    revElms.each( function( i) { 
     
    6967        var rev = $this.attr('kauri-role'); 
    7068        var assertElm = form.getElementIndex(index, rev).get(0); 
    71         equals(this, assertElm, "checked element index registration"); 
     69        equal(this, assertElm, "checked element index registration"); 
    7270    }); 
    7371} 
     
    9492 
    9593    var form = new $.org.kauriproject.forms.Form($form, fconf); 
     94 
    9695     
    9796    expect(12); 
     
    10099    var c = form.findControl(id); 
    101100    ok(c != null, "control creation passed"); 
    102     equals(c.getForm(), form, "control form ok"); 
    103     equals(c.getId(), id, "control id checked"); 
    104      
     101    ok(c.getForm() == form, "control form ok"); 
     102    equal(c.getId(), id, "control id checked"); 
     103 
    105104    // verify creation  of control elements 
    106105    var $input = $('input[kauri-idref*="'+id+'"]', $form); 
    107106    var $messages = $("span[kauri-idref*='"+id+"']", $form); 
    108107    $messages.html("text that should get cleared upon validation"); 
    109     isSet(c.getElement(), $input, "input element found and indexed."); 
    110     isSet(c.getElement('messages'), $messages, "messages element found and indexed.")   
     108    sameJq(c.getElement(), $input, "input element found and indexed."); 
     109    sameJq(c.getElement('messages'), $messages, "messages element found and indexed.")   
    111110     
    112111    // verify setting some value 
    113112    c.setWireValue(okValue); 
    114113 
    115     equals($messages.html(), "", "validation error clearing."); 
    116     equals(c.getValue(), okValue, "get-set value match."); 
     114    equal($messages.html(), "", "validation error clearing."); 
     115    equal(c.getValue(), okValue, "get-set value match."); 
    117116 
    118117     
     
    126125    $input.val(nokValue).change(); 
    127126 
    128     equals(changes, 1, "receiving value-change event"); 
    129     equals(c.hasChanges(), true, "change state") 
    130     equals($messages.html(), mockMsg, "validation error setting."); 
    131     equals(c.getValue(), nokValue, "get-set value match."); 
     127    equal(changes, 1, "receiving value-change event"); 
     128    equal(c.hasChanges(), true, "change state") 
     129    equal($messages.html(), mockMsg, "validation error setting."); 
     130    equal(c.getValue(), nokValue, "get-set value match."); 
    132131 
    133132    // mock user interaction: blur without change 
    134133    c.getElement("input").blur(); 
    135134 
    136     equals(changes, 1, "checking possible duplicate value-change event"); 
     135    equal(changes, 1, "checking possible duplicate value-change event"); 
    137136 
    138137    // cleanup 
     
    171170    var c = form.findControl(id); 
    172171    ok(c != null, "control creation passed"); 
    173     equals(c.getForm(), form, "control form ok"); 
    174     equals(c.getId(), id, "control id checked"); 
     172    ok(c.getForm() == form, "control form ok"); 
     173    equal(c.getId(), id, "control id checked"); 
    175174     
    176175    // verify creation  of control elements 
     
    178177    var $messages = $("span[kauri-idref*='"+id+"']", $form); 
    179178    $messages.html("text that should get cleared upon validation"); 
    180     isSet(c.getElement(), $input, "input element found and indexed."); 
    181     isSet(c.getElement('messages'), $messages, "messages element found and indexed.")   
     179    sameJq(c.getElement(), $input, "input element found and indexed."); 
     180    sameJq(c.getElement('messages'), $messages, "messages element found and indexed.")   
    182181     
    183182    // verify setting some value 
    184183    c.setWireValue(okValue); 
    185184 
    186     equals($messages.html(), "", "validation error clearing."); 
    187     equals(c.getValue(), okValue, "get-set value match."); 
     185    equal($messages.html(), "", "validation error clearing."); 
     186    equal(c.getValue(), okValue, "get-set value match."); 
    188187 
    189188     
     
    197196    $input.removeAttr('checked').click(); 
    198197 
    199     equals(changes, 1, "receiving value-change event"); 
    200     equals(c.hasChanges(), true, "change state"); 
    201     equals($messages.html(), mockMsg, "validation error setting."); 
    202     equals(c.getValue(), nokValue, "get-set value match."); 
     198    equal(changes, 1, "receiving value-change event"); 
     199    equal(c.hasChanges(), true, "change state"); 
     200    equal($messages.html(), mockMsg, "validation error setting."); 
     201    equal(c.getValue(), nokValue, "get-set value match."); 
    203202 
    204203    // mock user interaction: set 'true' again and check values 
    205204    $input.attr('checked', 'checked').click(); 
    206205 
    207     equals(changes, 2, "receiving 2nd value-change event"); 
    208     equals(c.hasChanges(), true, "change state");  
    209     equals($messages.html(), "", "validation error cleared."); 
    210     equals(c.getValue(), okValue, "get-set value match."); 
     206    equal(changes, 2, "receiving 2nd value-change event"); 
     207    equal(c.hasChanges(), true, "change state");  
     208    equal($messages.html(), "", "validation error cleared."); 
     209    equal(c.getValue(), okValue, "get-set value match."); 
    211210 
    212211    // cleanup 
     
    252251    var c = form.findControl(id); 
    253252    ok(c != null, "control creation passed"); 
    254     equals(c.getForm(), form, "control form ok"); 
    255     equals(c.getId(), id, "control id checked"); 
     253    ok(c.getForm() == form, "control form ok"); 
     254    equal(c.getId(), id, "control id checked"); 
    256255         
    257256    // verify setting some valid value in untrimmed version 
    258257    c.setWireValue(options[1]); 
    259     equals(c.getValue(), options[1], "checking that the untrimmed value was selected to second option"); 
     258    equal(c.getValue(), options[1], "checking that the untrimmed value was selected to second option"); 
    260259     
    261260    // verify setting untrimmed value via UI 
     
    265264    $options.eq(2).attr("selected","selected"); 
    266265    $input.change(); 
    267     equals(c.getValue(), options[2], "checking that the untrimmed value was selected to third option"); 
     266    equal(c.getValue(), options[2], "checking that the untrimmed value was selected to third option"); 
    268267     
    269268    // verify setting untrimmed value 
    270269    $input.val(options[3]); 
    271270    $input.change(); 
    272     equals(c.getValue(), options[3], "checking that the untrimmed value was selected to fourth option"); 
     271    equal(c.getValue(), options[3], "checking that the untrimmed value was selected to fourth option"); 
    273272     
    274273     
     
    316315    var c = form.findControl(id); 
    317316    ok(c != null, "control creation passed"); 
    318     equals(c.getForm(), form, "control form ok"); 
    319     equals(c.getId(), id, "control id checked"); 
     317    ok(c.getForm() == form, "control form ok"); 
     318    equal(c.getId(), id, "control id checked"); 
    320319     
    321320    // verify creation  of control elements 
     
    323322    var $messages = $("span[kauri-idref*='"+id+"']", $form); 
    324323    $messages.html("text that should get cleared upon validation"); 
    325     isSet(c.getElement(), $input, "input element found and indexed."); 
    326     isSet(c.getElement('messages'), $messages, "messages element found and indexed.")   
     324    sameJq(c.getElement(), $input, "input element found and indexed."); 
     325    sameJq(c.getElement('messages'), $messages, "messages element found and indexed.")   
    327326     
    328327    var $options = $("option", $input); 
    329     equals($options.length, options.length, "Checking if options are available on HTML level."); 
    330      
    331     isSet(c.getValue(), [3], "checking initial value."); 
     328    equal($options.length, options.length, "Checking if options are available on HTML level."); 
     329     
     330    deepEqual(c.getValue(), [3], "checking initial value."); 
    332331     
    333332    // verify setting some valid value 
    334333    c.setWireValue([3,4]); 
    335     equals($messages.html(), "", "validation error clearing."); 
    336     isSet(c.getValue(), [3,4], "get-set value match."); 
     334    equal($messages.html(), "", "validation error clearing."); 
     335    deepEqual(c.getValue(), [3,4], "get-set value match."); 
    337336    ok($options.eq(3).attr("selected"), "checking html option set"); 
    338337    ok(!$options.eq(6).attr("selected"), "checking html option not set"); 
    339     isSet(c.readUserValue(), ["3", "4"], "get-set value match on html level."); 
     338    deepEqual(c.readUserValue(), ["3", "4"], "get-set value match on html level."); 
    340339     
    341340     
     
    351350    $input.change(); 
    352351 
    353     equals(changes, 1, "receiving value-change event"); 
    354     equals(c.hasChanges(), true, "change state"); 
    355     isSet(c.getValue(), [1, 2], "get-set value match."); 
     352    equal(changes, 1, "receiving value-change event"); 
     353    equal(c.hasChanges(), true, "change state"); 
     354    deepEqual(c.getValue(), [1, 2], "get-set value match."); 
    356355 
    357356    c.setValue([1, 7]); 
    358     isSet(c.getValue(), [1], "get-set value trimmed to options."); 
     357    deepEqual(c.getValue(), [1], "get-set value trimmed to options."); 
    359358     
    360359     
     
    363362 
    364363}); 
     364 
     365}); 
     366 
     367 
    365368 
    366369function makeMockValidator( test) { 
     
    384387    return [ validator, errorMessage ]; 
    385388} 
     389 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-basic-fields.js

    r802 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Field Type Checking'); 
    24 
     
    5052}); 
    5153 
     54}); 
     55 
    5256function getFieldType( name, ext) { 
    5357 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-basic-formatters.js

    r1832 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Formatter logic testing.'); 
    24 
     
    100102 
    101103    // be:bank-account format 
    102         var f = getFormatter("pattern", { 
    103             pattern :"###-#######-##" 
    104         }); 
    105  
    106         assertConvert(f, "format", "737000003679", "737-0000036-79"); 
    107         assertConvert(f, "parse", "  737-0000036-79  ", "737000003679"); 
    108         assertFail(f, "format", "737"); 
    109         assertFail(f, "format", "a"); 
    110         assertFail(f, "format", "0737000003679"); 
     104    var f = getFormatter("pattern", { 
     105        pattern :"###-#######-##" 
    111106    }); 
    112107 
     108    assertConvert(f, "format", "737000003679", "737-0000036-79"); 
     109    assertConvert(f, "parse", "  737-0000036-79  ", "737000003679"); 
     110    assertFail(f, "format", "737"); 
     111    assertFail(f, "format", "a"); 
     112    assertFail(f, "format", "0737000003679"); 
     113}); 
     114 
     115}); 
    113116 
    114117function assertConvert( f, unc, input, out) { 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-basic-validators.js

    r1888 r1896  
     1$(document).ready(function(){ 
     2     
    13module('Validator logic testing.'); 
    24 
     
    132134test("isEmail", function() { 
    133135 
    134     expect(13); 
     136    expect(14); 
    135137 
    136138    var v = getValidator("isEmail"); 
     
    145147    valueCheck(v, "root@localhost.localdomain", true); 
    146148    valueCheck(v, "INFO@EXAMPLE.ORG", true); 
    147     valueCheck(v, "sdf@…@sdf....sdfsdf----+++564|@@@@99;;;;;", false); 
     149    valueCheck(v, "sdf@sdf.dsf@sdf....sdfsdf----+++564|@@@@99;;;;;", false); 
     150    valueCheck(v, "Some string with a valid email@address.test is not the same as a valid address!", false); 
    148151    valueCheck(v, ".@", false); 
    149152    valueCheck(v, "@.", false); 
     
    152155test("isUrl", function() { 
    153156 
    154     expect(11); 
     157    expect(12); 
    155158 
    156159    var v = getValidator("isUrl"); 
     
    164167    valueCheck(v, "https://example.com:8888/path", true); 
    165168    valueCheck(v, "https://example.com:888888/path", false); // port too big 
     169    valueCheck(v, "Some string with a http://valid/uri is not the same as a valid URI!", false); 
    166170    valueCheck(v, "https://127.0.0.1/", true); 
    167171    valueCheck(v, "no uri", false); 
     
    210214 
    211215    $.ajaxSetup({async: true}); // reset 
     216 
     217}); 
    212218 
    213219}); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-case.js

    r1879 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Case Type/Control Checking'); 
    24 
     
    4547    var c = form.findControl(id); 
    4648    ok(c != null, "control creation passed"); 
    47     equals(c.getForm(), form, "control form ok"); 
    48     equals(c.getId(), id, "control id checked"); 
     49    ok(c.getForm() == form, "control form ok"); 
     50    equal(c.getId(), id, "control id checked"); 
    4951 
    5052     
     
    5759     
    5860    var $c1Msg = form.findControl(id + "/case-c1").getElement("messages"); 
    59     equals($c1Msg.get(0), $c1.get(1), "lookup of messages element for input control."); 
     61    equal($c1Msg.get(0), $c1.get(1), "lookup of messages element for input control."); 
    6062 
    6163    var $c2Msg = form.findControl(id + "/case-c2").getElement("messages");; 
     
    162164  // cleanup 
    163165  $main.html("").hide(); 
    164       
     166   
    165167}); 
     168 
     169}); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-collection.js

    r1867 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Collection Control Testing'); 
    24 
     
    3234    var c = form.findControl(id); 
    3335    ok(c != null, "control creation passed"); 
    34     equals(c.getForm(), form, "control form ok"); 
    35     equals(c.getId(), id, "control id checked"); 
     36    ok(c.getForm() == form, "control form ok"); 
     37    equal(c.getId(), id, "control id checked"); 
    3638     
    3739    var changes = 0; 
     
    4244    c.setWireValue( [ okValue, nokValue ]); 
    4345    // check creation of child-controls? 
    44     equals(changes, 1, "initial setting of all values registered"); 
    45     equals(c.hasChanges(), false, "initial set values"); 
    46  
    47     // equals(validContainer.html(), "", "validation error cleared ok."); 
    48     equals(c.getValue()[0], okValue, "get-set value match - index 0"); 
    49     equals(c.getValue()[1], nokValue, "get-set value match - index 1."); 
    50  
    51     equals(c.getChildByIndex(0).getElement("messages").html(), "", "validation error cleared ok."); 
    52     equals(c.getChildByIndex(1).getElement("messages").html(), mockMsg, "validation error set correctly"); 
     46    equal(changes, 1, "initial setting of all values registered"); 
     47    equal(c.hasChanges(), false, "initial set values"); 
     48 
     49    // equal(validContainer.html(), "", "validation error cleared ok."); 
     50    equal(c.getValue()[0], okValue, "get-set value match - index 0"); 
     51    equal(c.getValue()[1], nokValue, "get-set value match - index 1."); 
     52 
     53    equal(c.getChildByIndex(0).getElement("messages").html(), "", "validation error cleared ok."); 
     54    equal(c.getChildByIndex(1).getElement("messages").html(), mockMsg, "validation error set correctly"); 
    5355 
    5456    // Mocking user interaction... 
    5557    c.findControl("0").getElement("input").val(nokValue).change(); 
    56     equals(changes, 2, "change detection"); 
     58    equal(changes, 2, "change detection"); 
    5759    c.findControl("1").getElement("input").val(okValue).change(); 
    58     equals(changes, 3, "change detection"); 
    59  
    60     // equals(validContainer.html(), nvalid.getMessage(), "validation error set correctly."); 
    61     equals(c.getValue()[0], nokValue, "get-set value match - index 0"); 
    62     equals(c.getValue()[1], okValue, "get-set value match - index 1."); 
    63  
    64     equals(c.getChildByIndex(0).getElement("messages").html(), mockMsg, "validation error set correctly"); 
    65     equals(c.getChildByIndex(1).getElement("messages").html(), "", "validation error cleared ok."); 
     60    equal(changes, 3, "change detection"); 
     61 
     62    // equal(validContainer.html(), nvalid.getMessage(), "validation error set correctly."); 
     63    equal(c.getValue()[0], nokValue, "get-set value match - index 0"); 
     64    equal(c.getValue()[1], okValue, "get-set value match - index 1."); 
     65 
     66    equal(c.getChildByIndex(0).getElement("messages").html(), mockMsg, "validation error set correctly"); 
     67    equal(c.getChildByIndex(1).getElement("messages").html(), "", "validation error cleared ok."); 
    6668 
    6769    // cleanup 
     
    113115    var c = form.findControl(id); 
    114116    ok(c != null, "control creation passed"); 
    115     equals(c.getForm(), form, "control form ok"); 
    116     equals(c.getId(), id, "control id checked"); 
     117    ok(c.getForm() == form, "control form ok"); 
     118    equal(c.getId(), id, "control id checked"); 
    117119     
    118120    var changes = 0; 
     
    128130        "m2" :true 
    129131    } ]); 
    130     equals(changes, 1, "registration of all initial setValue events"); 
     132    equal(changes, 1, "registration of all initial setValue events"); 
    131133 
    132134    var gotValue = c.getValue(); 
    133     equals(gotValue[0].m1, okValue, "get-set value match - member m1"); 
    134     equals(gotValue[0].m2, false, "get-set value match - member m2."); 
     135    equal(gotValue[0].m1, okValue, "get-set value match - member m1"); 
     136    equal(gotValue[0].m2, false, "get-set value match - member m2."); 
    135137    var m01 = c.findControl("0/m1"); 
    136     equals(m01.getElement("messages").html(), "", "validation error cleared ok."); 
    137     equals(gotValue[1].m1, nokValue, "get-set value match - member m1"); 
    138     equals(gotValue[1].m2, true, "get-set value match - member m2."); 
     138    equal(m01.getElement("messages").html(), "", "validation error cleared ok."); 
     139    equal(gotValue[1].m1, nokValue, "get-set value match - member m1"); 
     140    equal(gotValue[1].m2, true, "get-set value match - member m2."); 
    139141    var m02 = m01.findControl("../../1/m1"); 
    140     equals(m02.getElement("messages").html(), mockMsg, "validation error set correctly"); 
     142    equal(m02.getElement("messages").html(), mockMsg, "validation error set correctly"); 
    141143 
    142144 
     
    182184    var c = form.findControl(id); 
    183185    ok(c != null, "control creation passed"); 
    184     equals(c.getForm(), form, "control form ok"); 
    185     equals(c.getId(), id, "control id checked"); 
     186    ok(c.getForm() == form, "control form ok"); 
     187    equal(c.getId(), id, "control id checked"); 
    186188     
    187189    var changes = 0; 
     
    192194    c.setWireValue( [ okValue, nokValue ]); 
    193195     
    194     equals(changes, 1, "initial setting of all values registered"); 
    195     equals(c.hasChanges(), false, "initial set values"); 
     196    equal(changes, 1, "initial setting of all values registered"); 
     197    equal(c.hasChanges(), false, "initial set values"); 
    196198 
    197199  
    198200    // Mocking user interaction... 
    199201    c.findControl("0").getElement("input").val(okValue + "2").change(); 
    200     equals(changes, 2, "change detection"); 
     202    equal(changes, 2, "change detection"); 
    201203    c.findControl("1").getElement("input").val(okValue + "3").change(); 
    202     equals(changes, 3, "change detection"); 
    203      
    204      
    205     equals(c.getElement("messages").html(), $("<p>Length not in range 3 &#x2a7d; Length &#x2a7e; 6.</p>").html(), "validation error set correctly"); 
     204    equal(changes, 3, "change detection"); 
     205     
     206     
     207    equal(c.getElement("messages").html(), $("<p>Length not in range 3 &#x2a7d; Length &#x2a7e; 6.</p>").html(), "validation error set correctly"); 
    206208     
    207209    c.addChild().getElement("input").val(okValue + "4").change(); 
    208     equals(changes, 4, "change detection"); 
    209  
    210     equals(c.getElement("messages").html(), "", "validation error cleared"); 
     210    equal(changes, 4, "change detection"); 
     211 
     212    equal(c.getElement("messages").html(), "", "validation error cleared"); 
    211213     
    212214    // cleanup 
     
    246248     
    247249    ok(c != null, "control creation passed"); 
    248     equals(c.getForm(), form, "control form ok"); 
    249     equals(c.getId(), id, "control id checked"); 
    250      
    251     equals(c.viewState, $.org.kauriproject.forms.Control.STATE_HIDDEN, "initial hidden"); 
    252     equals(c.getElement().css('display'),'none', "initial hidden"); 
     250    ok(c.getForm() == form, "control form ok"); 
     251    equal(c.getId(), id, "control id checked"); 
     252     
     253    equal(c.viewState, $.org.kauriproject.forms.Control.STATE_HIDDEN, "initial hidden"); 
     254    equal(c.getElement().css('display'),'none', "initial hidden"); 
    253255 
    254256    c.hide(); 
    255257 
    256     equals(c.viewState, $.org.kauriproject.forms.Control.STATE_HIDDEN, "double check hidden"); 
    257     equals(c.getElement().css('display'),'none', "double check hidden"); 
     258    equal(c.viewState, $.org.kauriproject.forms.Control.STATE_HIDDEN, "double check hidden"); 
     259    equal(c.getElement().css('display'),'none', "double check hidden"); 
    258260     
    259261    c.show(); 
     
    265267        var child = c.findControl(""+i); 
    266268 
    267         equals(child.viewState, $.org.kauriproject.forms.Control.STATE_HIDDEN, "double check hidden for child " + i); 
    268         equals(child.getElement().css('display'),'none', "double check hidden for child " + i); 
     269        equal(child.viewState, $.org.kauriproject.forms.Control.STATE_HIDDEN, "double check hidden for child " + i); 
     270        equal(child.getElement().css('display'),'none', "double check hidden for child " + i); 
    269271    } 
    270272     
     
    312314    // baseline checks 
    313315    ok(c != null, "control creation passed"); 
    314     equals(c.getForm(), form, "control form ok"); 
    315     equals(c.getId(), id, "control id checked"); 
     316    ok(c.getForm() == form, "control form ok"); 
     317    equal(c.getId(), id, "control id checked"); 
    316318     
    317319    // test that there are 0 children initially 
    318     equals(0, c.getChildren().length, "collection control should have 0 children"); 
     320    equal(0, c.getChildren().length, "collection control should have 0 children"); 
    319321 
    320322    // find the 'ads' button and click it 
     
    325327 
    326328    // test that there is a child. 
    327     equals(1, c.getChildren().length, "collection control should have one element"); 
    328  
    329     // cleanup 
    330     $main.html("").hide(); 
    331 }); 
     329    equal(1, c.getChildren().length, "collection control should have one element"); 
     330 
     331    // cleanup 
     332    $main.html("").hide(); 
     333}); 
     334 
     335}); 
     336 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-composite.js

    r1870 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Composite Type/Control Checking'); 
    24 
     
    5153    var c = form.findControl(id); 
    5254    ok(c != null, "control creation passed"); 
    53     equals(c.getForm(), form, "control form ok"); 
    54     equals(c.getId(), id, "control id checked"); 
     55    ok(c.getForm() == form, "control form ok"); 
     56    equal(c.getId(), id, "control id checked"); 
    5557     
    5658    var changes = 0; 
     
    5961    }); 
    6062 
    61     equals(c.findControl("m1").getElement("messages").get(0), $m1.get(1), "lookup of messages element for input control."); 
     63    equal(c.findControl("m1").getElement("messages").get(0), $m1.get(1), "lookup of messages element for input control."); 
    6264 
    6365    ok(c.findControl("m2").getElement("messages"), "creation of messages element for checkbox control."); 
     
    6870    }); 
    6971 
    70     equals(changes, 1, "both members changes"); 
    71     equals(c.hasChanges(), false, "initial value set"); 
    72  
    73     // equals(validContainer.html(), "", "validation error cleared ok."); 
    74     equals(c.getValue().m1, okValue, "get-set value match - member m1"); 
    75     equals(c.getValue().m2, false, "get-set value match - member m2."); 
    76  
    77  
    78     equals(c.getChildren().m1.getElement("messages").html(), "", "validation error cleared ok."); 
     72    equal(changes, 1, "both members changes"); 
     73    equal(c.hasChanges(), false, "initial value set"); 
     74 
     75    // equal(validContainer.html(), "", "validation error cleared ok."); 
     76    equal(c.getValue().m1, okValue, "get-set value match - member m1"); 
     77    equal(c.getValue().m2, false, "get-set value match - member m2."); 
     78 
     79 
     80    equal(c.getChildren().m1.getElement("messages").html(), "", "validation error cleared ok."); 
    7981 
    8082    // Mocking user interaction... 
    8183    c.findControl("m1").getElement("input").val(nokValue).change(); 
    82     equals(changes, 2, "change detection"); 
     84    equal(changes, 2, "change detection"); 
    8385    c.findControl("m2").getElement("input").attr("checked", "checked").click(); 
    84     equals(changes, 3, "change detection"); 
    85  
    86     // equals(validContainer.html(), nvalid.getMessage(), "validation error set correctly."); 
    87     equals(c.getValue().m1, nokValue, "get-set value match - member m1"); 
    88     equals(c.getValue().m2, true, "get-set value match - member m2."); 
    89  
    90     equals(c.getChildren().m1.getElement("messages").html(), mockMsg, "validation error set correctly"); 
     86    equal(changes, 3, "change detection"); 
     87 
     88    // equal(validContainer.html(), nvalid.getMessage(), "validation error set correctly."); 
     89    equal(c.getValue().m1, nokValue, "get-set value match - member m1"); 
     90    equal(c.getValue().m2, true, "get-set value match - member m2."); 
     91 
     92    equal(c.getChildren().m1.getElement("messages").html(), mockMsg, "validation error set correctly"); 
    9193 
    9294    // cleanup 
     
    134136    var c = form.findControl(id); 
    135137    ok(c != null, "control creation passed"); 
    136     equals(c.getForm(), form, "control form ok"); 
    137     equals(c.getId(), id, "control id checked"); 
     138    ok(c.getForm() == form, "control form ok"); 
     139    equal(c.getId(), id, "control id checked"); 
    138140 
    139141    c.setWireValue( {"m1" : 5, "m2" : 2 }); 
    140142     
    141     isSet(c.getElement("messages"), $msg, "used created messages."); 
     143    sameJq(c.getElement("messages"), $msg, "used created messages."); 
    142144    ok(c.getElement("messages").html().indexOf("is not") == -1, "validation error set correctly"); 
    143145    c.findControl("m1").getElement("input").val(1).change(); 
     
    180182    var c = form.findControl(id); 
    181183    ok(c != null, "control creation passed"); 
    182     equals(c.getForm(), form, "control form ok"); 
    183     equals(c.getId(), id, "control id checked"); 
     184    ok(c.getForm() == form, "control form ok"); 
     185    equal(c.getId(), id, "control id checked"); 
    184186 
    185187    c.hide(); 
     
    201203    // cleanup 
    202204    $main.html("").hide(); 
    203 }); 
     205 
     206}); 
     207 
     208}); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-date.js

    r1849 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Date Testing type and control'); 
    24 
     
    198200    var c = form.findControl(id); 
    199201    ok(c != null, "control creation passed"); 
    200     equals(c.getForm(), form, "control form ok"); 
    201     equals(c.getId(), id, "control id checked"); 
     202    ok(c.getForm() == form, "control form ok"); 
     203    equal(c.getId(), id, "control id checked"); 
    202204     
    203205     
     
    214216    c.setWireValue(wireValue);      
    215217    ok($.valueCompare(okValue,c.getValue()), "get-set value match."); 
    216     equals(changes, 1, "missed a value-change event"); 
     218    equal(changes, 1, "missed a value-change event"); 
    217219     
    218220    // mock user interaction: change value to something that doesn't validate 
    219221    c.getChild("start").getElement("input").val(nokUserValue.start).change(); 
    220222    c.getChild("end").getElement("input").val(nokUserValue.end).change(); 
    221     equals(changes, 3, "missed a value-changed event"); 
    222      
    223     equals(c.hasChanges(), true, "change state"); 
     223    equal(changes, 3, "missed a value-changed event"); 
     224     
     225    equal(c.hasChanges(), true, "change state"); 
    224226    ok(c.getChild("start").getElement("messages").html().indexOf("Could not parse the date") >= 0, "validation error setting."); 
    225227    var val = c.getValue(); 
    226     equals(val, undefined, "get-set value match."); 
     228    equal(val, undefined, "get-set value match."); 
    227229 
    228230    // mock user interaction: change value trigger change 
    229231    c.getChild("start").getElement("input").val(okUserValue.start).change(); 
    230232    c.getChild("end").getElement("input").val(okUserValue.end).change(); 
    231     equals(changes, 5, "receiving value-change event"); 
    232     equals(c.hasChanges(), true, "change state") 
     233    equal(changes, 5, "receiving value-change event"); 
     234    equal(c.hasChanges(), true, "change state") 
    233235 
    234236    // cleanup 
     
    236238}); 
    237239 
    238  
    239 // TODO implement the datetime control 
     240//TODO implement the datetime control 
    240241/* 
    241242test("datetime-control", function() { 
     
    246247}); 
    247248*/ 
     249 
     250}); 
     251 
    248252function runDateControlTests (fieldTypeName, controlValues) { 
    249253 
     
    275279    var c = form.findControl(id); 
    276280    ok(c != null, "control creation passed"); 
    277     equals(c.getForm(), form, "control form ok"); 
    278     equals(c.getId(), id, "control id checked"); 
     281    ok(c.getForm() == form, "control form ok"); 
     282    equal(c.getId(), id, "control id checked"); 
    279283     
    280284    var changes = 0; 
     
    294298    c.setWireValue(wireValue); 
    295299 
    296     equals($msg.html(), "", "validation error clearing."); 
     300    equal($msg.html(), "", "validation error clearing."); 
    297301    ok($.valueCompare($.datepicker.parseDate("dd/mm/yy",okValue),c.getValue()), "get-set value match."); 
    298302     
    299303    // mock user interaction: change value to something that doesn't validate 
    300304    c.getElement("input").val(nokValue).change(); 
    301     equals(changes, 2, "this should not be receiving value-change events"); 
    302     equals(c.hasChanges(), true, "change state"); 
     305    equal(changes, 2, "this should not be receiving value-change events"); 
     306    equal(c.hasChanges(), true, "change state"); 
    303307    ok(String($msg.html()).indexOf("Could not parse the date") >= 0, "validation error setting."); 
    304     equals( c.getValue(), undefined, "get-set value match."); 
     308    equal( c.getValue(), undefined, "get-set value match."); 
    305309 
    306310    // mock user interaction: change value trigger change 
    307311    c.getElement("input").val(ok2Value).change(); 
    308     equals(changes, 3, "receiving value-change event"); 
    309     equals(c.hasChanges(), true, "change state") 
     312    equal(changes, 3, "receiving value-change event"); 
     313    equal(c.hasChanges(), true, "change state") 
    310314 
    311315    // cleanup 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-form.js

    r1873 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Form Checking'); 
    24 
     
    6062 
    6163                    var form = this.getForm(); 
    62                     equals(form.isComplete(), true, "checking form.isComplete while initializing..."); 
     64                    equal(form.isComplete(), true, "checking form.isComplete while initializing..."); 
    6365                    this.wiringCalls++; 
    6466                } 
     
    6971    var form = new $.org.kauriproject.forms.Form($form, fconf); 
    7072 
    71     equals(form.isComplete(), true, "checking form.isComplete after initializing..."); 
     73    equal(form.isComplete(), true, "checking form.isComplete after initializing..."); 
    7274    var m1c = form.findControl("/m1"); 
    73     equals(m1c.wiringCalls, 1, "checking wiring-call happened after initializing..."); 
     75    equal(m1c.wiringCalls, 1, "checking wiring-call happened after initializing..."); 
    7476 
    7577    // normally one should never be calling this directly, but test shows the initEventWiring will only be called once 
    7678    form.initComplete(); 
    77     equals(m1c.wiringCalls, 1, "checking wiring-call unregistered itself after execution..."); 
     79    equal(m1c.wiringCalls, 1, "checking wiring-call unregistered itself after execution..."); 
    7880 
    7981 
     
    8385    }); 
    8486 
    85     // equals(validContainer.html(), "", "validation error cleared ok."); 
    86     equals(form.getValue().m1, okValue, "get-set value match - member m1"); 
    87     equals(form.getValue().m2, false, "get-set value match - member m2."); 
    88  
    89     equals(form.getChildren().m1.getElement("messages").html(), "", "validation error cleared ok."); 
     87    // equal(validContainer.html(), "", "validation error cleared ok."); 
     88    equal(form.getValue().m1, okValue, "get-set value match - member m1"); 
     89    equal(form.getValue().m2, false, "get-set value match - member m2."); 
     90 
     91    equal(form.getChildren().m1.getElement("messages").html(), "", "validation error cleared ok."); 
    9092 
    9193    form.setValue( { 
     
    9496    }); 
    9597 
    96     // equals(validContainer.html(), nvalid.getMessage(), "validation error set correctly."); 
    97     equals(form.getValue().m1, nokValue, "get-set value match - member m1"); 
    98     equals(form.getValue().m2, true, "get-set value match - member m2."); 
    99  
    100     equals(form.getChildren().m1.getElement("messages").html(), mockMsg, "validation error set correctly"); 
     98    // equal(validContainer.html(), nvalid.getMessage(), "validation error set correctly."); 
     99    equal(form.getValue().m1, nokValue, "get-set value match - member m1"); 
     100    equal(form.getValue().m2, true, "get-set value match - member m2."); 
     101 
     102    equal(form.getChildren().m1.getElement("messages").html(), mockMsg, "validation error set correctly"); 
    101103 
    102104    // cleanup 
     
    152154     
    153155     
    154     equals(form.isComplete(), true, "checking form.isComplete after initializing..."); 
     156    equal(form.isComplete(), true, "checking form.isComplete after initializing..."); 
    155157    var m1c = form.findControl("/m1"); 
    156     equals(m1c.getType(), "FieldType('my-string')", "checking wiring-call happened after initializing..."); 
     158    equal(m1c.getType(), "FieldType('my-string')", "checking wiring-call happened after initializing..."); 
    157159     
    158160    // normally one should never be calling this directly, but test shows thet initEventWiring will only be called once 
    159161    form.initComplete(); 
    160     equals(m1c.getType(), "FieldType('my-string')", "checking wiring-call unregistered itself after execution..."); 
     162    equal(m1c.getType(), "FieldType('my-string')", "checking wiring-call unregistered itself after execution..."); 
    161163     
    162164     
     
    166168    }); 
    167169     
    168     //equals(validContainer.html(), "", "validation error cleared ok."); 
    169     equals(form.getValue().m1, "test", "get-set value match - member m1"); 
    170     equals(form.getValue().m2, false, "get-set value match - member m2."); 
    171      
    172     equals(form.getChildren().m1.getElement("messages").html(), "", "validation error cleared ok."); 
     170    //equal(validContainer.html(), "", "validation error cleared ok."); 
     171    equal(form.getValue().m1, "test", "get-set value match - member m1"); 
     172    equal(form.getValue().m2, false, "get-set value match - member m2."); 
     173     
     174    equal(form.getChildren().m1.getElement("messages").html(), "", "validation error cleared ok."); 
    173175     
    174176    form.setValue({ 
     
    177179    }); 
    178180     
    179     //equals(validContainer.html(), nvalid.getMessage(), "validation error set correctly."); 
    180     equals(form.getValue().m1, nokValue, "get-set value match - member m1"); 
    181     equals(form.getValue().m2, true, "get-set value match - member m2."); 
    182      
    183     equals(form.getChildren().m1.getElement("messages").html(), mockMsg, "validation error set correctly"); 
     181    //equal(validContainer.html(), nvalid.getMessage(), "validation error set correctly."); 
     182    equal(form.getValue().m1, nokValue, "get-set value match - member m1"); 
     183    equal(form.getValue().m2, true, "get-set value match - member m2."); 
     184     
     185    equal(form.getChildren().m1.getElement("messages").html(), mockMsg, "validation error set correctly"); 
    184186 
    185187    // cleanup 
     
    238240    }); 
    239241     
    240     equals(form.findControl('details/0/val1').getValue(), 51, "value checked"); 
    241     equals(form.findControl('details/1/val2').getValue(), 62, "value checked"); 
     242    equal(form.findControl('details/0/val1').getValue(), 51, "value checked"); 
     243    equal(form.findControl('details/1/val2').getValue(), 62, "value checked"); 
    242244     
    243245    // cleanup 
     
    313315    var $subOptions = $("option", $subSelect); 
    314316     
    315     equals($mainOptions.length, 2, "correct number of options on main");  
    316     equals(mainC.getValue(), 'weekdays', "checking initial value set ok"); 
    317      
    318     equals($subOptions.length, 7, "correct number of options on sub select"); 
    319     equals(subC.getValue(), 'mon', "checking initial value set ok"); 
     317    equal($mainOptions.length, 2, "correct number of options on main");  
     318    equal(mainC.getValue(), 'weekdays', "checking initial value set ok"); 
     319     
     320    equal($subOptions.length, 7, "correct number of options on sub select"); 
     321    equal(subC.getValue(), 'mon', "checking initial value set ok"); 
    320322     
    321323    // 1. set value on main & check updated list & updateOptions event 
     
    325327    $subOptions = $("option", $subSelect); 
    326328     
    327     equals(subUpdates, 0, "update of options triggered"); 
    328     equals($subOptions.length, 7, "correct number of options on sub select"); 
     329    equal(subUpdates, 0, "update of options triggered"); 
     330    equal($subOptions.length, 7, "correct number of options on sub select"); 
    329331     
    330332    // 2. set value on sub & check errors 
    331333    $subSelect.val('wed').change(); // fake user input 
    332     equals(subC.getValue(), 'wed', "checking value set ok"); 
    333     equals(subC.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
    334     equals(subC.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
     334    equal(subC.getValue(), 'wed', "checking value set ok"); 
     335    equal(subC.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
     336    equal(subC.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
    335337     
    336338    // 3. set other value on main & check - update list - updatedOptions event - check errors 
     
    338340    $subOptions = $("option", $subSelect); 
    339341     
    340     equals(subUpdates, 1, "update of options triggered"); 
    341     equals($subOptions.length, 12, "correct number of options on sub select"); 
    342     equals(subC.getValue(), 'jan', "checking initial value set ok"); 
    343     equals(subC.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
    344     equals(subC.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
     342    equal(subUpdates, 1, "update of options triggered"); 
     343    equal($subOptions.length, 12, "correct number of options on sub select"); 
     344    equal(subC.getValue(), 'jan', "checking initial value set ok"); 
     345    equal(subC.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
     346    equal(subC.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
    345347     
    346348    // 4. set other value on sub & check errors 
    347349    $subSelect.val('may').change(); // fake user input 
    348     equals(subC.getValue(), 'may', "checking value set ok"); 
    349     equals(subC.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
    350     equals(subC.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
     350    equal(subC.getValue(), 'may', "checking value set ok"); 
     351    equal(subC.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
     352    equal(subC.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
    351353         
    352354    // cleanup 
     
    433435    var $mainSelect = mainControl.getElement(); 
    434436    var $mainOptions = $("option", $mainSelect); 
    435     equals($mainOptions.length, 2, "correct number of options on main");  
    436     equals(mainControl.getValue(), 'weekdays', "checked initial value of main select");  
     437    equal($mainOptions.length, 2, "correct number of options on main");  
     438    equal(mainControl.getValue(), 'weekdays', "checked initial value of main select");  
    437439 
    438440    var $subSelects = new Array(num); 
     
    441443        var $subSelect = $subSelects[i]; 
    442444        var $subOptions = $("option", $subSelect); 
    443         equals($subOptions.length, 7, "correct number of options on sub select " + i); 
    444         equals(subControls[i].getValue(), 'mon', "checked initial value of sub select " + i); 
    445         equals(subControls[i].valueState, kf.Control.STATE_INIT, "checked initial value-state of sub select " + i); 
     445        equal($subOptions.length, 7, "correct number of options on sub select " + i); 
     446        equal(subControls[i].getValue(), 'mon', "checked initial value of sub select " + i); 
     447        equal(subControls[i].valueState, kf.Control.STATE_INIT, "checked initial value-state of sub select " + i); 
    446448    } 
    447449 
     
    452454    $mainSelect.val('weekdays').change(); // fake user input 
    453455 
    454     equals(subUpdates, 0, "update of options not triggered"); // no change compared to default value! options already loaded 
     456    equal(subUpdates, 0, "update of options not triggered"); // no change compared to default value! options already loaded 
    455457 
    456458    var w_set = ['mon', 'wed', 'fri']; 
     
    460462        var $subSelect = $subSelects[i]; 
    461463        var $subOptions = $("option", $subSelect); 
    462         equals($subOptions.length, 7, "correct number of options on sub select " + i); 
    463         equals(subControl.options, subOptions, "all options in the collection are shared. " + i); 
     464        equal($subOptions.length, 7, "correct number of options on sub select " + i); 
     465        ok(subControl.options == subOptions, "all options in the collection are shared. " + i); 
    464466 
    465467        // 2. set value on sub & check errors 
     
    469471        var subControl = subControls[i]; 
    470472         
    471         equals(subControl.getValue(), w_get[i], "checking value set ok"); 
    472         equals(subControl.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
    473         equals(subControl.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
     473        equal(subControl.getValue(), w_get[i], "checking value set ok"); 
     474        equal(subControl.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
     475        equal(subControl.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
    474476    } 
    475477     
     
    477479    // 3. set other value on main & check - update list - updatedOptions event - check errors 
    478480    $mainSelect.val('months').change(); // fake user input 
    479     equals(subUpdates, 1, "update of options triggered only once"); 
     481    equal(subUpdates, 1, "update of options triggered only once"); 
    480482 
    481483    var m_set = ['feb', 'xxx', 'sep']; 
     
    484486        var $subSelect = $subSelects[i]; 
    485487        var $subOptions = $("option", $subSelect); 
    486         equals($subOptions.length, 12, "correct number of options on sub select " + i); 
     488        equal($subOptions.length, 12, "correct number of options on sub select " + i); 
    487489 
    488490        // 4. set other value on sub & check errors 
     
    492494        var subControl = subControls[i]; 
    493495 
    494         equals(subControl.getValue(), m_get[i], "checking value set ok"); 
    495         equals(subControl.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
    496         equals(subControl.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
     496        equal(subControl.getValue(), m_get[i], "checking value set ok"); 
     497        equal(subControl.getElement('mark').hasClass('invalid'), false, "checking error cleared."); 
     498        equal(subControl.getElement('mark').hasClass('valid'), true, "checking error cleared."); 
    497499    } 
    498500 
     
    585587        var $mainSelect = mainControls[i].getElement(); 
    586588        var $mainOptions = $("option", $mainSelect); 
    587         equals($mainOptions.length, 2, "correct number of options on main " + i);  
    588         equals(mainControls[i].getValue(), 'weekdays', "checked initial value of main select " + i);  
     589        equal($mainOptions.length, 2, "correct number of options on main " + i);  
     590        equal(mainControls[i].getValue(), 'weekdays', "checked initial value of main select " + i);  
    589591 
    590592        var $subSelect = subControls[i].getElement(); 
    591593        var $subOptions = $("option", $subSelect); 
    592         equals($subOptions.length, 7, "correct number of options on sub select " + i); 
    593         equals(subControls[i].getValue(), 'mon', "checked initial value of sub select " + i);  
     594        equal($subOptions.length, 7, "correct number of options on sub select " + i); 
     595        equal(subControls[i].getValue(), 'mon', "checked initial value of sub select " + i);  
    594596 
    595597    } 
     
    618620 
    619621        expectedChanges[i] = (main_set[i] === 'weekdays') ? 0 : 1; 
    620         equals(subUpdates[i], expectedChanges[i], "update of options triggered " + i); 
     622        equal(subUpdates[i], expectedChanges[i], "update of options triggered " + i); 
    621623         
    622624        var $subSelect = subControls[i].getElement(); 
    623625        var $subOptions = $("option", $subSelect); 
    624         equals($subOptions.length, opt_lengths[main_set[i]], "correct number of options on sub select " + i); 
    625         equals(subType, commonSubType, "all types in the collection are shared. " + i); 
     626        equal($subOptions.length, opt_lengths[main_set[i]], "correct number of options on sub select " + i); 
     627        equal(subType, commonSubType, "all types in the collection are shared. " + i); 
    626628 
    627629        // 2. set value on sub & check errors 
     
    631633        var subControl = subControls[i]; 
    632634      //  var forced = true; 
    633         equals(subControl.getValue(), sub_set[i], "checking value set ok " + i); 
    634        // equals(subControl.isValid(forced), true, "forced validation yields ok " + i); 
    635         equals(subControl.getElement('mark').hasClass('invalid'), false, "checking error cleared. " + i); 
    636         equals(subControl.getElement('mark').hasClass('valid'), true, "checking error cleared." + i); 
     635        equal(subControl.getValue(), sub_set[i], "checking value set ok " + i); 
     636       // equal(subControl.isValid(forced), true, "forced validation yields ok " + i); 
     637        equal(subControl.getElement('mark').hasClass('invalid'), false, "checking error cleared. " + i); 
     638        equal(subControl.getElement('mark').hasClass('valid'), true, "checking error cleared." + i); 
    637639    } 
    638640 
     
    647649        var expectedUpdates = expectedChanges[i]; 
    648650        expectedUpdates += (main_set[i] === main_set2[i]) ?  0 : 1; 
    649         equals(subUpdates[i], expectedUpdates , "update of options triggered correctly " + i); 
     651        equal(subUpdates[i], expectedUpdates , "update of options triggered correctly " + i); 
    650652         
    651653        var $subSelect = subControls[i].getElement(); 
    652654        var $subOptions = $("option", $subSelect); 
    653         equals($subOptions.length, opt_lengths[main_set2[i]], "correct number of options on sub select " + i); 
     655        equal($subOptions.length, opt_lengths[main_set2[i]], "correct number of options on sub select " + i); 
    654656 
    655657        // 2. set value on sub & check errors 
     
    658660    for (var i = 0; i<num; i++){ 
    659661        var subControl = subControls[i]; 
    660         equals(subControl.getValue(), sub_set2[i], "checking value set ok " + i); 
    661         equals(subControl.getElement('mark').hasClass('invalid'), false, "checking error cleared." + i); 
    662         equals(subControl.getElement('mark').hasClass('valid'), true, "checking error cleared. " + i); 
     662        equal(subControl.getValue(), sub_set2[i], "checking value set ok " + i); 
     663        equal(subControl.getElement('mark').hasClass('invalid'), false, "checking error cleared." + i); 
     664        equal(subControl.getElement('mark').hasClass('valid'), true, "checking error cleared. " + i); 
    663665    } 
    664666     
     
    832834        } 
    833835         
    834         equals($casus.hasClass('valid'), valid, "casus should be " + classValidDescr + ".("+when+")"); 
    835         equals($casus.hasClass('invalid'), false, "including no invalid markers.("+when+")"); 
    836         equals(casus.isValid(false), valid, "casus has never been validated, it should be " + classValidDescr + ".("+when+")"); 
    837         equals(casus.isValid(true), true, "but it should be actually valid when checking it.("+when+")"); 
    838         equals($casus.hasClass('valid'), true, "and after checking should be marked as such.("+when+")"); 
    839         equals($casus.hasClass('invalid'), false, "not even invalid ones.("+when+")"); 
    840  
    841         equals($compos.hasClass('valid'), valid, "compos should be " + classValidDescr + ".("+when+")"); 
    842         equals($compos.hasClass('invalid'), false, "and not invalid.("+when+")"); 
    843         equals(compos.isValid(false), valid, "compos has never been validated, it should be " + classValidDescr + ".("+when+")"); 
    844         equals(compos.isValid(true), true, "but it should be actually valid when checking it.("+when+")"); 
    845         equals($compos.hasClass('valid'), true, "and after checking should be marked as such because it has an own validator.("+when+")"); 
    846         equals($compos.hasClass('invalid'), false, "and thus not have an invalid mark.("+when+")"); 
    847  
    848         equals($form.hasClass('valid'), valid, "form should be " + classValidDescr + ".("+when+")"); 
    849         equals($form.hasClass('invalid'), false, "including no invalid markers.("+when+")"); 
    850         equals(form.isValid(false), valid, "form has never been validated, it should be " + classValidDescr + ".("+when+")"); 
    851         equals(form.isValid(true), true, "but it turns out to be valid if we really check it.("+when+" and forced validation)"); 
    852         equals($form.hasClass('valid'), true, "and should also carry the mark. ("+when+" and forced validation)"); 
    853         equals($form.hasClass('invalid'), false, "including no invalid markers.("+when+" and forced validation)"); 
     836        equal($casus.hasClass('valid'), valid, "casus should be " + classValidDescr + ".("+when+")"); 
     837        equal($casus.hasClass('invalid'), false, "including no invalid markers.("+when+")"); 
     838        equal(casus.isValid(false), valid, "casus has never been validated, it should be " + classValidDescr + ".("+when+")"); 
     839        equal(casus.isValid(true), true, "but it should be actually valid when checking it.("+when+")"); 
     840        equal($casus.hasClass('valid'), true, "and after checking should be marked as such.("+when+")"); 
     841        equal($casus.hasClass('invalid'), false, "not even invalid ones.("+when+")"); 
     842 
     843        equal($compos.hasClass('valid'), valid, "compos should be " + classValidDescr + ".("+when+")"); 
     844        equal($compos.hasClass('invalid'), false, "and not invalid.("+when+")"); 
     845        equal(compos.isValid(false), valid, "compos has never been validated, it should be " + classValidDescr + ".("+when+")"); 
     846        equal(compos.isValid(true), true, "but it should be actually valid when checking it.("+when+")"); 
     847        equal($compos.hasClass('valid'), true, "and after checking should be marked as such because it has an own validator.("+when+")"); 
     848        equal($compos.hasClass('invalid'), false, "and thus not have an invalid mark.("+when+")"); 
     849 
     850        equal($form.hasClass('valid'), valid, "form should be " + classValidDescr + ".("+when+")"); 
     851        equal($form.hasClass('invalid'), false, "including no invalid markers.("+when+")"); 
     852        equal(form.isValid(false), valid, "form has never been validated, it should be " + classValidDescr + ".("+when+")"); 
     853        equal(form.isValid(true), true, "but it turns out to be valid if we really check it.("+when+" and forced validation)"); 
     854        equal($form.hasClass('valid'), true, "and should also carry the mark. ("+when+" and forced validation)"); 
     855        equal($form.hasClass('invalid'), false, "including no invalid markers.("+when+" and forced validation)"); 
    854856    } 
    855857     
     
    857859    expect(1 + 3*18); 
    858860     
    859     isSet(form.getElement(), $form,  "the form is the form of course"); 
     861    sameJq(form.getElement(), $form,  "the form is the form of course"); 
    860862    assertValidState("after creation"); // validstate of css is unmarked 
    861863 
     
    869871    // cleanup 
    870872    $main.html("").hide(); 
    871 }); 
     873 
     874}); 
     875 
     876}); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/test-numeric-range.js

    r1849 r1896  
     1$(document).ready(function(){ 
     2 
    13module('Numeric-range testing type and control'); 
    24 
     
    4850    var c = form.findControl(id); 
    4951    ok(c != null, "control creation passed"); 
    50     equals(c.getForm(), form, "control form ok"); 
    51     equals(c.getId(), id, "control id checked");     
     52    ok(c.getForm() == form, "control form ok"); 
     53    equal(c.getId(), id, "control id checked");     
    5254     
    5355     
     
    99101    var c = form.findControl(id); 
    100102    ok(c != null, "control creation passed"); 
    101     equals(c.getForm(), form, "control form ok"); 
    102     equals(c.getId(), id, "control id checked");     
     103    ok(c.getForm() == form, "control form ok"); 
     104    equal(c.getId(), id, "control id checked");     
    103105     
    104106   
     
    118120    $slider.slider('values', 1, 7); $slider.slider('values', 0, 4); 
    119121    var wireval = c.getWireValue(); 
    120     equals(wireval.start, 4, "The control start member should have the same value as the input"); 
    121     equals(wireval.end,  7, "The control end member should have the same value as the input"); 
     122    equal(wireval.start, 4, "The control start member should have the same value as the input"); 
     123    equal(wireval.end,  7, "The control end member should have the same value as the input"); 
    122124     
    123125    $main.html("").hide(); 
     126 
    124127}); 
     128 
     129}); 
  • trunk/modules/kauri-forms/kauri-forms-framework/src/test/kauri.forms/testPage.html

    r1864 r1896  
    55  <title>Kauri Forms Main Test Page</title> 
    66 
    7   <link rel="Stylesheet" media="screen" href="../../../../../kauri-jquery/src/test/qunit/testsuite.css" /> 
    8   <script type="text/javascript" src="../../../../../kauri-jquery/src/main/kauri/static/jquery/jquery-1.4.1/jquery-1.4.1.js"></script> 
    9   <script type="text/javascript" src="../../../../../kauri-jquery/src/test/qunit/testrunner.js"></script> 
     7  <link rel="Stylesheet" media="screen" href="../../../../../kauri-jquery/src/test/qunit/qunit.css" /> 
     8  <style type="text/css" > 
     9    .qunit-like { 
     10      padding: 0.5em 0.5em 0.5em 2.5em; 
     11      color: #2B81AF; 
     12      background-color: #D2E0E6; 
     13      border-bottom: 1px solid white;  
     14      font-size: small;  
     15      margin: 0; 
     16    } 
     17  </style> 
     18  <script type="text/javascript" src="../../../../../kauri-jquery/src/main/kauri/static/jquery/jquery-1.5.2/jquery-1.5.2.js"></script> 
     19  <script type="text/javascript" src="../../../../../kauri-jquery/src/test/qunit/qunit.js"></script> 
    1020 
    1121  <!--  Dependencies --> 
     
    1525  <script type="text/javascript" src="../../../../../kauri-jquery/src/main/kauri/static-{build}.key/kauri.util/locale.js" ></script> 
    1626 
    17   <script type="text/javascript" src="../../../../../kauri-jquery/src/main/kauri/static/jquery.ui/jquery.ui-1.7.1/js/jquery-ui-1.7.1.min.js"></script> 
     27  <script type="text/javascript" src="../../../../../kauri-jquery/src/main/kauri/static/jquery.ui/jquery.ui-1.8.11/js/jquery-ui-1.8.11.min.js"></script> 
    1828     
    1929 
     
    4656    //tests assume some standard locale setting 
    4757    //we override those! 
    48     ; 
     58    var kf = $.org.kauriproject.forms; 
     59 
     60    function sameJq(first, second, msg) { 
     61        if (first == null || second == null || first.length != second.length) 
     62            fail(msg); 
     63        for (var i=0; i<first.length; i++) 
     64            if (first.get(i) != second.get(i)) 
     65                fail(msg + " -- not same @index=" + i); 
     66        ok(true, msg); 
     67    }; 
     68     
    4969    (function($){ 
    50         var locale = $.org.kauriproject.forms.locale; 
     70        var locale = kf.locale; 
    5171        locale.setId('en-US'); 
    5272        locale.separator['decimal'] = '.'; 
    5373        locale.separator['1000'] = ','; 
    5474        locale.timezone = 0; 
    55     })(jQuery);     
     75    })(jQuery);    
     76 
    5677  </script> 
    5778  <script type="text/javascript" src="test-basic-validators.js" ></script> 
     
    6586  <script type="text/javascript" src="test-date.js" ></script> 
    6687  <script type="text/javascript" src="test-numeric-range.js" ></script> 
     88    
    6789  <!-- Haven't found a way to test the control since the page has to be completly loaded to be able to load the maps api 
    6890  <script type="text/javascript" src="test-location.js" ></script> 
    6991  --> 
     92 
     93  <!--   
    7094  <link rel="stylesheet" href="../../main/kauri/public/css/datepicker.css"/> 
     95  --> 
    7196  <!-- TODO link to css of ui theme --> 
    7297   
     
    7499 
    75100<body id="body"> 
    76   <h1 id="header">Kauri Forms Main Test Page</h1> 
    77   <h2 id="banner"></h2> 
    78   <h2 id="userAgent"></h2> 
    79   <h2>Note: to run these tests in google chrome: close all instances and start-up with --allow-file-access-from-files</h2> 
     101  <h1 id="qunit-header">Kauri Forms Main Test Page</h1> 
     102  <h2 id="qunit-banner"></h2> 
     103  <div id="qunit-testrunner-toolbar"></div> 
     104  <h2 id="qunit-userAgent"></h2> 
     105  <h2 class="qunit-like"> 
     106    Note: to run these tests in google chrome: close all instances and start-up with --allow-file-access-from-files 
     107  </h2> 
     108   
     109  <!-- Test HTML --> 
     110  <div id="main" style="display: none;"></div> 
    80111 
    81   <!-- Test HTML --> 
    82   <div id="main" style="display: none;"> 
    83  
    84   </div> 
     112  <ol id="qunit-tests"></ol> 
     113  <div id="qunit-fixture">test markup, will be hidden</div> 
    85114  <ol id="tests"></ol> 
    86115</body> 
Note: See TracChangeset for help on using the changeset viewer.