web/test/jstests/test_utils.js
changeset 9259 68cde7431c2c
parent 8879 982a49239420
child 10426 ce213d6858f1
equal deleted inserted replaced
9258:4e79f587c6ab 9259:68cde7431c2c
    45   });
    45   });
    46 
    46 
    47   module("sliceList");
    47   module("sliceList");
    48   test("test slicelist", function() {
    48   test("test slicelist", function() {
    49       var list = ['a', 'b', 'c', 'd', 'e', 'f'];
    49       var list = ['a', 'b', 'c', 'd', 'e', 'f'];
    50       same(sliceList(list, 2),  ['c', 'd', 'e', 'f']);
    50       same(cw.utils.sliceList(list, 2),  ['c', 'd', 'e', 'f']);
    51       same(sliceList(list, 2, -2), ['c', 'd']);
    51       same(cw.utils.sliceList(list, 2, -2), ['c', 'd']);
    52       same(sliceList(list, -3), ['d', 'e', 'f']);
    52       same(cw.utils.sliceList(list, -3), ['d', 'e', 'f']);
    53       same(sliceList(list, 0, -2), ['a', 'b', 'c', 'd']);
    53       same(cw.utils.sliceList(list, 0, -2), ['a', 'b', 'c', 'd']);
    54       same(sliceList(list),  list);
    54       same(cw.utils.sliceList(list),  list);
    55   });
    55   });
    56 
    56 
    57   module("formContents", {
    57   module("formContents", {
    58     setup: function() {
    58     setup: function() {
    59       $('#main').append('<form id="test-form"></form>');
    59       $('#main').append('<form id="test-form"></form>');
    81       //Append an unchecked radio input : should not be in formContents list
    81       //Append an unchecked radio input : should not be in formContents list
    82       $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
    82       $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
    83 			     'value="one" />');
    83 			     'value="one" />');
    84       $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
    84       $('#test-form').append('<input name="unchecked-choice" type="radio" ' +
    85 			     'value="two"/>');
    85 			     'value="two"/>');
    86       same(formContents($('#test-form')[0]), [
    86       same(cw.utils.formContents($('#test-form')[0]), [
    87 	['input-text', 'mytextarea', 'choice', 'check', 'theselect'],
    87 	['input-text', 'mytextarea', 'choice', 'check', 'theselect'],
    88 	['toto', 'Hello World!', 'no', 'no', 'foo']
    88 	['toto', 'Hello World!', 'no', 'no', 'foo']
    89       ]);
    89       ]);
    90   });
    90   });
    91 });
    91 });