recordset.html revision d291538c94e99bf25eb23d4ecb9ff41f6527389c
base: "/build/",
var ASSERT = Y.Assert,
ARRAYASSERT = Y.ArrayAssert,
BTNRUN = Y.get("#btnRun");
BTNRUN.set("disabled", false);
Y.on("click", function(e){
var myConsole = new Y.Console().render();
var testBasic = new Y.Test.Case({
delete this.rs;
this.rs.on('change', function() {
this.rs.on('empty', function() {
Y.Assert.isTrue(flag);
// var iD = this.initialData, i=0;
// this.rs.on('update', function(e) {
// Y.ObjectAssert.areEqual(delRecords, e.data.overwritten.getValue(), "old record values match up");
newRecord = this.rs.getRecord(1);
newRecord = this.rs.getRecords(1,2);
var oRec = new Y.Record({a:'234'});
if (obj instanceof Y.Record) {
// console.log(oRec);
// console.log(obj);
retval = this.rs.add(recToAdd);
//This is indirectly checking to make sure that the record that got added has the identical data as the object literal that was passed in.
this.changeTest(3);
retval = this.rs.add(recToAdd,i);
this.changeTest(i);
retval = this.rs.add(recsToAdd);
this.changeTest(3);
retval = this.rs.add(recsToAdd, i);
this.changeTest(i);
this.rs.on('remove', function(e) {
this.changeTest(2);
this.changeTest(1);
this.rs.on('remove', function(e) {
this.rs.remove(1);
this.rs.on('remove', function(e) {
this.changeTest(1);
this.rs.remove(1,2);
this.emptyTest(0);
retval = this.rs.getValuesByKey(key);
Y.Assert.isUndefined(retval[i]);
newRecord = new Y.Record({data:{a:'newA', b:'newB', c:'newC'}});
oldRecord = this.rs.getRecord(index);
this.rs.on('update', function(e) {
Y.ObjectAssert.areEqual(oldRecord, e.data.overwritten[0], 'Overwritten record is != to old record');
this.rs.update(newRecord, index);
oldRecord = this.rs.getRecord(index);
a = new Y.Record({data:{a:'newA', b:'newB', c:'newC'}});
b = new Y.Record({data:{a:'newD', b:'newE', c:'newF'}});
newRecords.push(a);
newRecords.push(b);
this.rs.on('update', function(e) {
Y.ObjectAssert.areEqual(oldRecord, e.data.overwritten[0], 'Overwritten record is != to old record');
this.rs.update(newRecords, index);
newRecord = new Y.Record({data: {a:'newG', b:'newH', c:'newI'}});
oldRecord = this.rs.getRecord(index);
this.rs.on('update', function(e) {
Y.ObjectAssert.areEqual(oldRecord, e.data.overwritten[0], 'Overwritten record is != to old record');
this.rs.update(newRecord, index, true);
oldRecords = this.rs.getRecords(index,3);
//console.log(oldRecords);
a = new Y.Record({data:{a:'newA', b:'newB', c:'newC'}});
b = new Y.Record({data:{a:'newD', b:'newE', c:'newF'}});
c = new Y.Record({data:{a:'newG', b:'newH', c:'newI'}});
newRecords.push(a);
newRecords.push(b);
newRecords.push(c);
this.rs.on('update', function(e) {
//Y.ObjectAssert.areEqual(oldRecords[i].getValue(), e.data.overwritten[i].getValue(), 'Overwritten record is != to old record');
Y.ObjectAssert.areEqual(oData, e.data.updated[0].getValue(), 'Updated record != equal to new record');
Y.ObjectAssert.areEqual(oldRecord, e.data.overwritten[0], 'Overwritten record != equal to old record');
newRecord = new Y.Record({data:o});
oldRecord = this.rs.getRecord(index);
this.rs.on('update', function(e) {
this.rs.update(newRecord, index);
oldRecord = this.rs.getRecords(index,2);
a = new Y.Record({data:{a:'newA', b:'newB', c:'newC'}});
b = new Y.Record({data:{a:'newD', b:'newE', c:'newF'}});
newRecords.push(a);
newRecords.push(b);
this.rs.on('update', function(e) {
this.rs.update(newRecords, index);
this.rs.sort.sort('a',false);
this.rs.sort.sort('c',true);
this.rs.sort.sort('b',true);
this.rs.sort.sort('a',false);
this.rs.add({a:6,b:5,c:8});
this.rs.add([d,c,b,a]);
this.rs.add([d,c,b,a]);
this.rs.sort.sort('a',true);
//This is just a copy of Y.ArraySort.compare
if(!Y.Lang.isValue(a)) {
if(!Y.Lang.isValue(b)) {
else if(!Y.Lang.isValue(b)) {
if(Y.Lang.isString(a)) {
if(Y.Lang.isString(b)) {
this.rs.add([a,b,c,d]);
this.rs.sort.sort('a',false,customsort);
if (item.getValue('b') === 2) {
var rs = this.rs.filter.filter(validator);
if (item.getValue('c') === 2) {
rs = this.rs.filter.filter(validator);
rs = this.rs.filter.filter('b',2);
if (item.getValue('b') === 2) {
rs = this.rs.filter.reject(validator);
if (item.getValue('c') === 2) {
rs = this.rs.filter.reject(validator);
//Map is tested on the actual array because it returns an array of booleans typically (atleast that's the use case I can think of)
if (item.getValue('b') === 2) {
Y.Assert.areEqual(true, rs[0]);
Y.Assert.areEqual(false, rs[1]);
Y.Assert.areEqual(true, rs[2]);
var suite = new Y.Test.Suite({name:"Recordset Test Suite"});
suite.add(testBasic);
Y.Test.Runner.setName("Recordset Test Runner");
Y.Test.Runner.add(suite);