upgrading to YUI 2.6
data tables are going to need some work yet, but the other stuff seems to be working 100%
This commit is contained in:
parent
a041e93da8
commit
20f8df1291
2106 changed files with 993560 additions and 237 deletions
151
www/extras/yui/tests/datatable/219708.html
Normal file
151
www/extras/yui/tests/datatable/219708.html
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Test Page</title>
|
||||
<link type="text/css" rel="stylesheet" href="/assets/dpSyntaxHighlighter.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/logger/assets/logger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/yuitest/assets/testlogger.css">
|
||||
<link type="text/css" rel="stylesheet" href="../../build/paginator/assets/skins/sam/paginator.css">
|
||||
<style type="text/css" class="highlight-ignore">
|
||||
h1 {
|
||||
font: normal 125%/1.4 Arial, sans-serif;
|
||||
}
|
||||
.yui-log {
|
||||
display: inline;
|
||||
float: right;
|
||||
position: relative;
|
||||
}
|
||||
.yui-log-container {
|
||||
width: 300px;
|
||||
}
|
||||
.yui-log .yui-log-bd {
|
||||
height: 525px;
|
||||
}
|
||||
.yui-log .yui-log-ft {
|
||||
position: static;
|
||||
}
|
||||
.highlight-example {
|
||||
display: inline;
|
||||
float: left;
|
||||
width: 650px;
|
||||
}
|
||||
.highlight-example h2 {
|
||||
display: none;
|
||||
}
|
||||
.yui-log-bd h3 {
|
||||
border-bottom: 1px solid #ccc;
|
||||
color: #900;
|
||||
margin: 0;
|
||||
padding: 1em 0 0 1ex;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="yui-skin-sam">
|
||||
<h1>Tests</h1>
|
||||
<div id="testbed"></div>
|
||||
|
||||
<script type="text/javascript" src="../../build/yahoo-dom-event/yahoo-dom-event.js"></script>
|
||||
<script type="text/javascript" src="../../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../../build/yuitest/yuitest-min.js"></script>
|
||||
<script type="text/javascript" src="../../build/element/element-beta.js"></script>
|
||||
<script type="text/javascript" src="../../build/datasource/datasource-beta.js"></script>
|
||||
<script type="text/javascript" src="../../build/datatable/datatable-beta.js"></script>
|
||||
<script type="text/javascript">
|
||||
(function () {
|
||||
|
||||
var t = YAHOO.tool,
|
||||
u = YAHOO.util,
|
||||
w = YAHOO.widget,
|
||||
TestSuite = t.TestSuite,
|
||||
TestCase = t.TestCase,
|
||||
TestLogger = t.TestLogger,
|
||||
TestRunner = t.TestRunner,
|
||||
Event = u.Event,
|
||||
Dom = u.Dom,
|
||||
Assert = u.Assert,
|
||||
AAssert = u.ArrayAssert,
|
||||
OAssert = u.ObjectAssert,
|
||||
DataSource = u.DataSource,
|
||||
DataTable = w.DataTable,
|
||||
testbed = Dom.get('testbed'),
|
||||
suite;
|
||||
|
||||
suite = new TestSuite("Tests");
|
||||
|
||||
suite.add(new TestCase({
|
||||
name : "Test Case",
|
||||
|
||||
setUp : function () {
|
||||
function formatText(cell,r,c,data) {
|
||||
cell.className += ' foo';
|
||||
DataTable.formatText(cell,r,c,data);
|
||||
}
|
||||
function formatDefault(cell,r,c,data) {
|
||||
cell.className += ' bar';
|
||||
DataTable.formatDefault(cell,r,c,data);
|
||||
}
|
||||
|
||||
this.dataSource = new DataSource({ recs : [{a:'P&I', b:'PB&J'}]}, {
|
||||
responseType: DataSource.TYPE_JSON,
|
||||
responseSchema: { resultsList: 'recs', fields : ['a','b'] }
|
||||
});
|
||||
|
||||
this.colDef = [
|
||||
{key: 'a'},
|
||||
{key: 'b'},
|
||||
{key: 'a', formatter: formatText},
|
||||
{key: 'b', formatter: formatText},
|
||||
{key: 'a', formatter: formatDefault},
|
||||
{key: 'b', formatter: formatDefault}
|
||||
]
|
||||
},
|
||||
tearDown : function () {
|
||||
//this.dataTable.destroy();
|
||||
},
|
||||
|
||||
testDefaultFormatter : function () {
|
||||
this.dataTable = new DataTable(testbed,this.colDef,this.dataSource);
|
||||
|
||||
var cells = Dom.getElementsByClassName('yui-dt-liner','div',
|
||||
this.dataTable.getTbodyEl()),i;
|
||||
|
||||
// TODO: how to test other than by eye?
|
||||
function ins(c) {
|
||||
var n = document.createTextNode(c.innerHTML);
|
||||
testbed.parentNode.insertBefore(n,testbed.nextSibling);
|
||||
}
|
||||
|
||||
ins(cells[5]);
|
||||
ins(cells[1]);
|
||||
ins(cells[4]);
|
||||
ins(cells[0]);
|
||||
}
|
||||
}));
|
||||
|
||||
Event.onDOMReady(function () {
|
||||
|
||||
var logger = new TestLogger("log");
|
||||
logger.hideCategory('info');
|
||||
logger.formatMsg = function (e) {
|
||||
if (e.category === 'section') {
|
||||
return "<h3>"+e.msg+"</h3>";
|
||||
} else if (e.category === "break") {
|
||||
return "<br>";
|
||||
} else {
|
||||
return TestLogger.prototype.formatMsg.call(this,e);
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.log("Tests","section","TestRunner");
|
||||
|
||||
TestRunner.add(suite);
|
||||
|
||||
TestRunner.run();
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
<script type="text/javascript" src="/assets/dpSyntaxHighlighter.js"></script>
|
||||
<script type="text/javascript" src="/assets/dpSyntaxHighlightExample.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
152
www/extras/yui/tests/datatable/ColumnSet.js
vendored
Normal file
152
www/extras/yui/tests/datatable/ColumnSet.js
vendored
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
(function() {
|
||||
var gCount = -1;
|
||||
|
||||
var Dom=YAHOO.util.Dom,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert,
|
||||
DateAssert=YAHOO.util.DateAssert,
|
||||
UserAction=YAHOO.util.UserAction,
|
||||
TestCase = YAHOO.tool.TestCase,
|
||||
TestLogger = YAHOO.tool.TestLogger,
|
||||
TestRunner = YAHOO.tool.TestRunner,
|
||||
TestSuite = YAHOO.tool.TestSuite,
|
||||
|
||||
DataSource = YAHOO.util.DataSource,
|
||||
DataTable = YAHOO.widget.DataTable,
|
||||
ColumnSet = YAHOO.widget.ColumnSet,
|
||||
RecordSet = YAHOO.widget.RecordSet;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Base DataTable test template. Sets up values for a DataTable instance.
|
||||
*
|
||||
*
|
||||
*/
|
||||
var dtBaseTemplate = {
|
||||
name: "DataTable Base Tests",
|
||||
|
||||
dsData: [
|
||||
{a:"0a",b:"0b",c:"0c"},
|
||||
{a:"1a",b:"1b",c:"1c"},
|
||||
{a:"2a",b:"2b",c:"2c"},
|
||||
{a:"3a",b:"3b",c:"3c"}
|
||||
],
|
||||
|
||||
dsConfig: {
|
||||
responseType:YAHOO.util.DataSource.TYPE_JSARRAY,
|
||||
responseSchema:{fields:["a","b","c"]}
|
||||
},
|
||||
|
||||
columns: [{key:"a"},{key:"b"},{key:"c"}]
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Base DataTable test case.
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DataTableTestCase(template) {
|
||||
DataTableTestCase.superclass.constructor.call(this, template);
|
||||
};
|
||||
YAHOO.lang.extend(DataTableTestCase, TestCase);
|
||||
|
||||
DataTableTestCase.prototype.setUp = function() {
|
||||
// Create container anew
|
||||
this.container = document.createElement("div");
|
||||
///this.container.id = "testDTContainer"; // Is this necessary?
|
||||
document.body.appendChild(this.container);
|
||||
|
||||
// Create DataSource anew
|
||||
this.datasource = new YAHOO.util.DataSource(this.dsData, this.dsConfig);
|
||||
};
|
||||
|
||||
DataTableTestCase.prototype.tearDown = function() {
|
||||
// Destroy DataTable
|
||||
this.datatable.destroy();
|
||||
this.datatable = null;
|
||||
|
||||
// Destroy container
|
||||
if(this.container !== null) {
|
||||
YAHOO.util.Event.purgeElement(this.container, true);
|
||||
document.body.removeChild(this.container);
|
||||
this.container = null;
|
||||
}
|
||||
|
||||
// TODO: need a destroy method
|
||||
this.datasource = null;
|
||||
};
|
||||
|
||||
DataTableTestCase.prototype.createInstance = function(oDT, oConfig) {
|
||||
oDT = oDT || DataTable;
|
||||
this.datatable = new oDT(this.container, this.columns, this.datasource, oConfig);
|
||||
gCount++;
|
||||
return this.datatable;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Tests ColumnSet APIs.
|
||||
*
|
||||
*
|
||||
*/
|
||||
var csColumnSetTemplate = YAHOO.lang.merge(dtBaseTemplate, {
|
||||
name: "DataTable ColumnSet Tests",
|
||||
|
||||
testGetColumnSet: function() {
|
||||
var dt = this.createInstance();
|
||||
var cs = dt.getColumnSet();
|
||||
|
||||
Assert.isInstanceOf(ColumnSet, cs, "Expected a ColumnSet");
|
||||
},
|
||||
|
||||
testGetColumn: function() {
|
||||
var dt = this.createInstance();
|
||||
//dt.subscribe("initEvent", function() {
|
||||
var cs = dt.getColumnSet();
|
||||
var oColumn = cs.keys[0];
|
||||
var sColId = oColumn.getId();
|
||||
|
||||
var el = dt.getTheadEl().rows[0].cells[0];
|
||||
var oTestColumn = dt.getColumn(el);
|
||||
Assert.areSame(oColumn, oTestColumn, "Expected to get Column by el reference");
|
||||
|
||||
//TODO: get column by el reference child
|
||||
|
||||
// Removed col elements
|
||||
//el = Dom.get(dt.getId()+"-col"+sColId);
|
||||
//oTestColumn = dt.getColumn(el);
|
||||
//Assert.areSame(oColumn, oTestColumn, "Expected to get Column by DOM ID");
|
||||
|
||||
oTestColumn = dt.getColumn(0);
|
||||
Assert.areSame(oColumn, oTestColumn, "Expected to get Column by key index");
|
||||
|
||||
oTestColumn = cs.getColumn("a");
|
||||
Assert.areSame(oColumn, oTestColumn, "Expected to get Column by key (ColumnSet method)");
|
||||
|
||||
oTestColumn = cs.getColumnById(sColId);
|
||||
Assert.areSame(oColumn, oTestColumn, "Expected to get Column by Column ID (ColumnSet method)");
|
||||
//});
|
||||
}
|
||||
|
||||
//TODO: More ColumnSet APIs
|
||||
});
|
||||
var csColumnSetTest = new DataTableTestCase(csColumnSetTemplate);
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Runs tests.
|
||||
*
|
||||
*
|
||||
*/
|
||||
YAHOO.util.Event.addListener(window, "load", function() {
|
||||
var columnsetsuite = new TestSuite("ColumnSet Test Suite");
|
||||
columnsetsuite.add(csColumnSetTest);
|
||||
|
||||
TestRunner.add(columnsetsuite);
|
||||
});
|
||||
})();
|
||||
1494
www/extras/yui/tests/datatable/DataTable.js
vendored
Normal file
1494
www/extras/yui/tests/datatable/DataTable.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
196
www/extras/yui/tests/datatable/RecordSet.js
vendored
Normal file
196
www/extras/yui/tests/datatable/RecordSet.js
vendored
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
(function() {
|
||||
var gCount = -1;
|
||||
|
||||
var Dom=YAHOO.util.Dom,
|
||||
Assert=YAHOO.util.Assert,
|
||||
ObjectAssert=YAHOO.util.ObjectAssert,
|
||||
ArrayAssert=YAHOO.util.ArrayAssert,
|
||||
DateAssert=YAHOO.util.DateAssert,
|
||||
UserAction=YAHOO.util.UserAction,
|
||||
TestCase = YAHOO.tool.TestCase,
|
||||
TestLogger = YAHOO.tool.TestLogger,
|
||||
TestRunner = YAHOO.tool.TestRunner,
|
||||
TestSuite = YAHOO.tool.TestSuite,
|
||||
|
||||
DataSource = YAHOO.util.DataSource,
|
||||
DataTable = YAHOO.widget.DataTable,
|
||||
ColumnSet = YAHOO.widget.ColumnSet,
|
||||
RecordSet = YAHOO.widget.RecordSet;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Base DataTable test template. Sets up values for a DataTable instance.
|
||||
*
|
||||
*
|
||||
*/
|
||||
var dtBaseTemplate = {
|
||||
name: "DataTable Base Tests",
|
||||
|
||||
dsData: [
|
||||
{a:"0a",b:"0b",c:"0c"},
|
||||
{a:"1a",b:"1b",c:"1c"},
|
||||
{a:"2a",b:"2b",c:"2c"},
|
||||
{a:"3a",b:"3b",c:"3c"}
|
||||
],
|
||||
|
||||
dsConfig: {
|
||||
responseType:YAHOO.util.DataSource.TYPE_JSARRAY,
|
||||
responseSchema:{fields:["a","b","c"]}
|
||||
},
|
||||
|
||||
columns: [{key:"a"},{key:"b"},{key:"c"}]
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Base DataTable test case.
|
||||
*
|
||||
*
|
||||
*/
|
||||
function DataTableTestCase(template) {
|
||||
DataTableTestCase.superclass.constructor.call(this, template);
|
||||
};
|
||||
YAHOO.lang.extend(DataTableTestCase, TestCase);
|
||||
|
||||
DataTableTestCase.prototype.setUp = function() {
|
||||
// Create container anew
|
||||
this.container = document.createElement("div");
|
||||
///this.container.id = "testDTContainer"; // Is this necessary?
|
||||
document.body.appendChild(this.container);
|
||||
|
||||
// Create DataSource anew
|
||||
this.datasource = new YAHOO.util.DataSource(this.dsData, this.dsConfig);
|
||||
};
|
||||
|
||||
DataTableTestCase.prototype.tearDown = function() {
|
||||
// Destroy DataTable
|
||||
this.datatable.destroy();
|
||||
this.datatable = null;
|
||||
|
||||
// Destroy container
|
||||
if(this.container !== null) {
|
||||
YAHOO.util.Event.purgeElement(this.container, true);
|
||||
document.body.removeChild(this.container);
|
||||
this.container = null;
|
||||
}
|
||||
|
||||
// TODO: need a destroy method
|
||||
this.datasource = null;
|
||||
};
|
||||
|
||||
DataTableTestCase.prototype.createInstance = function(oDT, oConfig) {
|
||||
oDT = oDT || DataTable;
|
||||
this.datatable = new oDT(this.container, this.columns, this.datasource, oConfig);
|
||||
gCount++;
|
||||
return this.datatable;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Tests RecordSet APIs.
|
||||
*
|
||||
*
|
||||
*/
|
||||
var rsRecordSetTemplate = YAHOO.lang.merge(dtBaseTemplate, {
|
||||
name: "DataTable RecordSet Tests",
|
||||
|
||||
testGetRecordSet: function() {
|
||||
var dt = this.createInstance();
|
||||
var rs = dt.getRecordSet();
|
||||
|
||||
Assert.isInstanceOf(RecordSet, rs, "Expected a RecordSet");
|
||||
},
|
||||
|
||||
testGetRecord: function() {
|
||||
var dt = this.createInstance();
|
||||
//dt.subscribe("initEvent", function() {
|
||||
var rs = dt.getRecordSet();
|
||||
var oRecord = rs._records[3];
|
||||
var sRecordId = oRecord.getId();
|
||||
|
||||
var el = dt.getTbodyEl().rows[3];
|
||||
var oTestRecord = dt.getRecord(el);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by el reference");
|
||||
|
||||
var el = dt.getTbodyEl().rows[3].cells[2];
|
||||
oTestRecord = dt.getRecord(el);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by el reference child");
|
||||
|
||||
el = Dom.get(oTestRecord.getId());
|
||||
oTestRecord = null;
|
||||
oTestRecord = dt.getRecord(el);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by DOM ID");
|
||||
|
||||
oTestRecord = dt.getRecord(3);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by position index");
|
||||
|
||||
oTestRecord = dt.getRecord(sRecordId);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by Record ID");
|
||||
|
||||
oTestRecord = dt.getRecord(oRecord);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by Record instance");
|
||||
|
||||
oTestRecord = rs.getRecord(3);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by position index (RecordSet method)");
|
||||
|
||||
oTestRecord = rs.getRecord(sRecordId);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by Record ID (RecordSet method)");
|
||||
|
||||
oTestRecord = rs.getRecord(oRecord);
|
||||
Assert.areSame(oRecord, oTestRecord, "Expected to get Record by Record instance (RecordSet method)");
|
||||
//});
|
||||
},
|
||||
|
||||
testGetInvalidRecord: function() {
|
||||
var dt = this.createInstance();
|
||||
//dt.subscribe("initEvent", function() {
|
||||
var rs = dt.getRecordSet();
|
||||
var oRecord = rs._records[3];
|
||||
dt.deleteRow(3);
|
||||
|
||||
oTestRecord = dt.getRecord(oRecord);
|
||||
Assert.areSame(null, oTestRecord, "Expected not to get Record by invalid Record instance");
|
||||
|
||||
oTestRecord = rs.getRecord(oRecord);
|
||||
Assert.areSame(null, oTestRecord, "Expected not to get Record by invalid Record instance (RecordSet method)");
|
||||
//});
|
||||
},
|
||||
|
||||
testUpdateKey: function() {
|
||||
var dt = this.createInstance();
|
||||
//dt.subscribe("initEvent", function() {
|
||||
var rs = dt.getRecordSet();
|
||||
var oTestRecord = rs._records[0];
|
||||
rs.updateKey(0, "b", "xxx");
|
||||
Assert.areSame("xxx", oTestRecord.getData("b"), "Failed to update key b of Record 0 by position index");
|
||||
|
||||
rs.updateKey(oTestRecord, "b", "zzz");
|
||||
Assert.areSame("zzz", oTestRecord.getData("b"), "Failed to update key b of Record 0 by instance");
|
||||
|
||||
rs.updateKey(oTestRecord.getId(), "b", "yyy");
|
||||
Assert.areSame("yyy", oTestRecord.getData("b"), "Failed to update key b of Record 0 by ID");
|
||||
//});
|
||||
}
|
||||
|
||||
|
||||
//TODO: More RecordSet APIs
|
||||
});
|
||||
var rsRecordSetTest = new DataTableTestCase(rsRecordSetTemplate);
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Runs tests.
|
||||
*
|
||||
*
|
||||
*/
|
||||
YAHOO.util.Event.addListener(window, "load", function() {
|
||||
var recordsetsuite = new TestSuite("RecordSet Test Suite");
|
||||
recordsetsuite.add(rsRecordSetTest);
|
||||
|
||||
TestRunner.add(recordsetsuite);
|
||||
});
|
||||
})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue