/** * Created with JetBrains PhpStorm. * User: taoqili * Date: 13-2-21 * Time: 下午1:31 * To change this template use File | Settings | File Templates. */ function getTable(str) { var div = document.getElementById("testTable"); if(!div){ div = document.createElement("div"); div.id = "testTable"; document.body.appendChild(div); } div.innerHTML = "" + str + "
"; return div.firstChild; } UT = UE.UETable; test("create UETable",function(){ var table = getTable("ddd"), ut = new UT(table); ok(ut.table === table,"UT对象创建成功"); ok(ut.colsNum == 1 && ut.rowsNum == 1,"单元格行、列数为1"); }); test("getMaxRows",function(){ var table = getTable("123" + "123"), ut = new UT(table); var maxRows = ut.getMaxRows(); equal(maxRows,2,"最大行数为2"); table = getTable("123" + "2"); ut = new UT(table); maxRows = ut.getMaxRows(); equal(maxRows,3,"最大行数为3"); }); test("getMaxCols",function(){ var table = getTable("123" + "123"), ut = new UT(table); var maxCols = ut.getMaxCols(); equal(maxCols,3,"最大列数为3"); table = getTable("123" + "2"); ut = new UT(table); maxCols = ut.getMaxCols(); equal(maxCols,6,"最大列数为6"); }); test("getSameEndPosCells",function(){ var table = getTable("123" + "23"), ut = new UT(table); var cell = table.rows[0].cells[0], cells1 = ut.getSameEndPosCells(cell,"x"), cells2 = ut.getSameEndPosCells(cell,"y"); ok(cells1.length == 1, "获取到同样X轴结尾位置的cell1个"); ok(cells2.length == 2, "获取到同样Y轴结尾位置的cell2个"); });