Permalink
Browse files

Add test for getRecord(id)

  • Loading branch information...
1 parent 123d994 commit 678b2ccc8fdf1f418f36f4e92d1a411c22e76c9f @lsmith committed Mar 15, 2012
Showing with 60 additions and 6 deletions.
  1. +30 −3 src/datatable/tests/datatable-body-tests.js
  2. +30 −3 src/datatable/tests/src/datatable-body.js
@@ -226,9 +226,9 @@ suite.add(new Y.Test.Case({
'c'
],
data: [
- { a: 1, b: 1, c: 1 },
- { a: 2, b: 2, c: 2 },
- { a: 3, b: 3, c: 3 }
+ { a: 'a1', b: 1, c: 1 },
+ { a: 'a2', b: 2, c: 2 },
+ { a: 'a3', b: 3, c: 3 }
]
}).render();
},
@@ -255,6 +255,33 @@ suite.add(new Y.Test.Case({
this.table._tbodyNode.one('em')));
},
+ "getRecord(model.id) should return the corresponding Model": function () {
+ var M = Y.Base.create('testModel', Y.Model, [], {
+ idAttribute: 'a'
+ }, {
+ ATTRS: {
+ a: {},
+ b: {},
+ c: {}
+ }
+ }),
+ table = new Y.DataTable({
+ columns: [ 'a', 'b', 'c' ],
+ data: [
+ { a: 'a1', b: 1, c: 1 },
+ { a: 'a2', b: 2, c: 2 },
+ { a: 'a3', b: 3, c: 3 }
+ ],
+ recordType: M
+ });
+
+ // For proper cleanup
+ this.table.destroy();
+ this.table = table;
+
+ Y.Assert.areSame(table.data.item(0), table.getRecord('a1'));
+ },
+
"getRecord(model.clientId) should return the corresponding Model": function () {
Y.Assert.areSame(this.table.data.item(0),
this.table.getRecord(
@@ -224,9 +224,9 @@ suite.add(new Y.Test.Case({
'c'
],
data: [
- { a: 1, b: 1, c: 1 },
- { a: 2, b: 2, c: 2 },
- { a: 3, b: 3, c: 3 }
+ { a: 'a1', b: 1, c: 1 },
+ { a: 'a2', b: 2, c: 2 },
+ { a: 'a3', b: 3, c: 3 }
]
}).render();
},
@@ -253,6 +253,33 @@ suite.add(new Y.Test.Case({
this.table._tbodyNode.one('em')));
},
+ "getRecord(model.id) should return the corresponding Model": function () {
+ var M = Y.Base.create('testModel', Y.Model, [], {
+ idAttribute: 'a'
+ }, {
+ ATTRS: {
+ a: {},
+ b: {},
+ c: {}
+ }
+ }),
+ table = new Y.DataTable({
+ columns: [ 'a', 'b', 'c' ],
+ data: [
+ { a: 'a1', b: 1, c: 1 },
+ { a: 'a2', b: 2, c: 2 },
+ { a: 'a3', b: 3, c: 3 }
+ ],
+ recordType: M
+ });
+
+ // For proper cleanup
+ this.table.destroy();
+ this.table = table;
+
+ Y.Assert.areSame(table.data.item(0), table.getRecord('a1'));
+ },
+
"getRecord(model.clientId) should return the corresponding Model": function () {
Y.Assert.areSame(this.table.data.item(0),
this.table.getRecord(

0 comments on commit 678b2cc

Please sign in to comment.