~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/tests/recordset/tests/recordset.html

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
 
<html>
3
 
<head>
4
 
<title>Recordset Tests</title>
5
 
<script type="text/javascript" src="../../../build/yui/yui-min.js"></script>
6
 
</head>
7
 
 
8
 
<body class="yui3-skin-sam">
9
 
<h1>Recordset Tests</h1>
10
 
<p><input type="button" value="Run Tests" id="btnRun" disabled=true></p>
11
 
 
12
 
<script type="text/javascript">
13
 
(function() {
14
 
    YUI({
15
 
        filter: (window.location.search.match(/[?&]filter=([^&]+)/) || [])[1] || 'min',
16
 
        allowRollup: false
17
 
    }).use("console", "test", "dump", "recordset", function(Y) {
18
 
        
19
 
 
20
 
        // Set up the page
21
 
        var ASSERT = Y.Assert,
22
 
            ARRAYASSERT = Y.ArrayAssert,
23
 
            BTNRUN = Y.one("#btnRun");
24
 
        BTNRUN.set("disabled", false);
25
 
        Y.on("click", function(e){
26
 
            Y.Test.Runner.run();
27
 
        }, BTNRUN);
28
 
        var myConsole = new Y.Console().render();
29
 
                
30
 
 
31
 
        var testBasic = new Y.Test.Case({
32
 
            name: "API Tests",
33
 
                        initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
34
 
 
35
 
                    //---------------------------------------------
36
 
                    // Setup and tear down
37
 
                    //---------------------------------------------
38
 
 
39
 
                    setUp : function () {
40
 
                        
41
 
                                //create recordset
42
 
                                this.rs = new Y.Recordset({records:this.initialData});
43
 
 
44
 
                                //Some Ways to access recordset properties
45
 
                                //Y.log(rs.getRecordByIndex(0).getValue('a'));
46
 
                        //Y.log(rs.get('records').length);
47
 
                    },
48
 
 
49
 
                    tearDown : function () {
50
 
                        delete this.rs;
51
 
                    },
52
 
                
53
 
                    //---------------------------------------------
54
 
                    // Event Helpers
55
 
                    //---------------------------------------------
56
 
                
57
 
                        changeTest: function(i) {
58
 
                                this.rs.on('change', function() {
59
 
                                        //Y.Assert.areEqual(e.index, i);
60
 
                                });
61
 
                        },
62
 
                        
63
 
                        emptyTest: function() {
64
 
                                var flag = false;
65
 
                                this.rs.on('empty', function() {
66
 
                                        flag = true;
67
 
                                        Y.Assert.isTrue(flag);
68
 
                                });
69
 
                                
70
 
                        },
71
 
                        
72
 
                        //---------------------------------------------
73
 
                    // Instantiation
74
 
                    //---------------------------------------------
75
 
 
76
 
                        testCreateEmptyRecordset: function() {
77
 
                                var rs = new Y.Recordset(),
78
 
                                        rem;
79
 
                                        
80
 
                                rs.on('remove', function(e) {
81
 
                                        rem = e.removed;
82
 
                                });
83
 
                                
84
 
                                //instantiate empty recordset
85
 
                                Y.Assert.isTrue(rs instanceof Y.Recordset);
86
 
                                
87
 
                                
88
 
                                //perform operations on it
89
 
                                rs.add({a:1, b:2, c:3});
90
 
                                Y.ObjectAssert.areEqual(rs.getRecord(0).getValue(), {a:1, b:2, c:3});
91
 
                                
92
 
                                rs.add([{a:'hey', b:'yo', c:'hi!'}, {a:2, b:5, c:6}]);
93
 
                                Y.ObjectAssert.areEqual(rs.getRecord(2).getValue(), {a:2, b:5, c:6});
94
 
                                Y.Assert.areEqual(3, rs.getLength());
95
 
                                
96
 
                                rs.remove(2);
97
 
                                Y.Assert.areEqual(2, rs.getLength());
98
 
                                Y.ObjectAssert.areEqual(rem[0].getValue(), {a:2, b:5, c:6});
99
 
                                
100
 
                        },
101
 
                        
102
 
                        //---------------------------------------------
103
 
                    // Get Records
104
 
                    //---------------------------------------------
105
 
                        
106
 
                        testGetRecords: function() {
107
 
                                var newRecord,newRecord1, newRecord2, id;
108
 
                                //this.rs.get('records');
109
 
                                // var newrs = new Y.Recordset({records: [{a:10,b:10,c:10}]});
110
 
                                // newrs.get('records');                
111
 
                                                
112
 
                                //Single Record
113
 
                                newRecord1 = this.rs.getRecordByIndex(1);
114
 
                                newRecord2 = this.rs.getRecord(1);
115
 
                                
116
 
                                Y.ObjectAssert.areEqual(newRecord1.getValue(), this.initialData[1]);
117
 
                                Y.ObjectAssert.areEqual(newRecord1, newRecord2);
118
 
                                
119
 
                                
120
 
                                //Multiple Records
121
 
                                newRecord = this.rs.getRecordsByIndex(1,2);
122
 
                                Y.ObjectAssert.areEqual(newRecord[0].getValue(), this.initialData[1]);
123
 
                                Y.ObjectAssert.areEqual(newRecord[1].getValue(), this.initialData[2]);
124
 
                                
125
 
                                //By ID
126
 
                                id = this.rs.getRecordByIndex(0).get('id');
127
 
                                newRecord = this.rs.getRecord(id);
128
 
                                Y.ObjectAssert.areEqual(newRecord, this.rs.getRecordByIndex(0));
129
 
                        },
130
 
                
131
 
                        //---------------------------------------------
132
 
                    // Add Records
133
 
                    //---------------------------------------------
134
 
 
135
 
            testAddSingleRecordToEnd: function() {
136
 
                                var recToAdd = {a:'8', b:'9', c:'10'}, retval;
137
 
                                retval = this.rs.add(recToAdd);
138
 
                                //Test Recordset Length
139
 
                                Y.Assert.areEqual(4, this.rs.get('records').length, "Array lengths not equal.");
140
 
                                //Assert on last object
141
 
                                
142
 
                                //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.
143
 
                                Y.ObjectAssert.areEqual(recToAdd, this.rs.getRecordByIndex(3).getValue());
144
 
                                Y.ObjectAssert.areEqual(retval.getRecordByIndex(3).getValue(3), recToAdd);
145
 
                                this.changeTest(3);
146
 
                                
147
 
            },
148
 
 
149
 
                        testAddSingleRecordToIndex: function() {
150
 
                                var recToAdd, i=2;
151
 
                                recToAdd = {a:'8', b:'9', c:'10'};
152
 
                                
153
 
                                retval = this.rs.add(recToAdd,i);
154
 
                                Y.Assert.areEqual(recToAdd, this.rs.getRecordByIndex(i).getValue());
155
 
                                
156
 
                                //assertion with output
157
 
                                Y.ObjectAssert.areEqual(retval.getRecordByIndex(i).getValue(), recToAdd);
158
 
 
159
 
                                this.changeTest(i);
160
 
                                
161
 
 
162
 
                                
163
 
                        },
164
 
                        
165
 
                        testAddMultipleRecordsToEnd: function() {
166
 
                                var recsToAdd = [{a:'11', b:'22', c:'33'}, {a:'44', b:'55', c:'66'}];
167
 
                                retval = this.rs.add(recsToAdd);
168
 
                                
169
 
                                //Assertions with recordset
170
 
                                Y.ObjectAssert.areEqual(recsToAdd[0], this.rs.getRecordByIndex(3).getValue());
171
 
                                Y.ObjectAssert.areEqual(recsToAdd[1], this.rs.getRecordByIndex(4).getValue());
172
 
                                
173
 
                                //assertions with output
174
 
                                Y.ObjectAssert.areEqual(retval.getRecordByIndex(3).getValue(), recsToAdd[0]);
175
 
                                Y.ObjectAssert.areEqual(retval.getRecordByIndex(4).getValue(), recsToAdd[1]);
176
 
                                
177
 
                                this.changeTest(3);
178
 
                                
179
 
                        },
180
 
                        
181
 
                        testAddMultipleRecordsToIndex: function() {
182
 
                                var recsToAdd, i;
183
 
                                recsToAdd = [{a:'11', b:'22', c:'33'}, {a:'44', b:'55', c:'66'}];
184
 
                                i = 1;
185
 
                                
186
 
                                retval = this.rs.add(recsToAdd, i);
187
 
                                
188
 
                                //Assertions with recordset
189
 
                                Y.ObjectAssert.areEqual(recsToAdd[0], this.rs.getRecordByIndex(1).getValue());
190
 
                                Y.ObjectAssert.areEqual(recsToAdd[1], this.rs.getRecordByIndex(2).getValue());
191
 
                                
192
 
                                this.changeTest(i);
193
 
                        },
194
 
                        
195
 
                        //---------------------------------------------
196
 
                    // Delete Records
197
 
                    //---------------------------------------------
198
 
                
199
 
                        testDeleteSingleRecordFromEnd: function() {
200
 
                                var rem;
201
 
                                this.rs.on('remove', function(e) {
202
 
                                        rem = e;
203
 
                                })
204
 
                                
205
 
                                this.changeTest(2);
206
 
                                this.rs.remove();
207
 
                                Y.ObjectAssert.areEqual(this.initialData[2], rem.removed[0].getValue());
208
 
                                Y.Assert.areEqual(2, rem.index);
209
 
                        }, 
210
 
                        
211
 
                        testDeleteSingleRecordFromIndex: function() {
212
 
                                this.changeTest(1);
213
 
                                var rem;
214
 
                                this.rs.on('remove', function(e) {
215
 
                                        rem = e;
216
 
                                });
217
 
                                this.rs.remove(1);
218
 
                                Y.ObjectAssert.areEqual(this.initialData[1], rem.removed[0].getValue());
219
 
                                Y.Assert.areEqual(1, rem.index);
220
 
                        },
221
 
                        
222
 
                        testDeleteRangeOfRecords: function() {
223
 
                                //Delete 2 records from index 1
224
 
                                var rem;
225
 
                                this.rs.on('remove', function(e) {
226
 
                                        rem = e;
227
 
                                });
228
 
                                
229
 
                                this.changeTest(1);
230
 
                                this.rs.remove(1,2);
231
 
                                
232
 
                                Y.ObjectAssert.areEqual(this.initialData[1], rem.removed[0].getValue());
233
 
                                Y.ObjectAssert.areEqual(this.initialData[2], rem.removed[1].getValue());
234
 
                                Y.Assert.areEqual(1, rem.index);
235
 
                        },
236
 
                        
237
 
                        //---------------------------------------------
238
 
                    // Empty Recordset
239
 
                    //---------------------------------------------
240
 
                        
241
 
                        testEmptyRecordSet: function() {
242
 
                                
243
 
                                this.emptyTest(0);
244
 
                                this.rs.empty();
245
 
                                Y.Assert.areEqual(0, this.rs.get('records').length);
246
 
                                
247
 
                        },
248
 
                        
249
 
                        //---------------------------------------------
250
 
                    // GetValuesByKey
251
 
                    //---------------------------------------------
252
 
                
253
 
                        testGetValuesByKey: function() {
254
 
                                var key, retval, i;
255
 
                                key = 'a';
256
 
                                retval = this.rs.getValuesByKey(key);
257
 
                                
258
 
                                for (i=0; i < this.initialData.length; i++) {
259
 
                                        Y.Assert.areEqual(this.initialData[i][key], retval[i]);
260
 
                                }
261
 
                        },
262
 
                        
263
 
                        testGetValuesByKeyWithInvalidKey: function() {
264
 
                                var key = 'd';
265
 
                                retval = this.rs.getValuesByKey(key);
266
 
                                
267
 
                                for (i=0; i < this.initialData.length; i++) {
268
 
                                        Y.Assert.isUndefined(retval[i]);
269
 
                                }
270
 
                        },
271
 
 
272
 
                        testUpdateRecordAtIndex: function() {
273
 
                                var newRecord, oldRecord, index=1;
274
 
                                var o = {a:'newG', b:'newH', c:'newI'};
275
 
                                newRecord = new Y.Record({data:o});
276
 
                                oldRecord = this.rs.getRecordByIndex(index);
277
 
                                
278
 
                                this.rs.on('update', function(e) {
279
 
                                        Y.ObjectAssert.areEqual(newRecord, e.updated[0], 'Updated record is != to new record');
280
 
                                        Y.ObjectAssert.areEqual(oldRecord, e.overwritten[0], 'Overwritten record is != to old record');
281
 
                                        Y.Assert.areEqual(1, e.overwritten.length, 'overwritten array is not of expected length');
282
 
                                        Y.Assert.areEqual(1, e.updated.length);
283
 
                                        Y.Assert.areEqual(index, e.index, "correct index was modified");
284
 
                                });
285
 
                                
286
 
                                
287
 
                                this.rs.update(newRecord, index);
288
 
                                Y.ObjectAssert.areEqual(newRecord.getValue(), this.rs.getRecordByIndex(index).getValue());
289
 
                        },
290
 
                        
291
 
                        testUpdateRecordAtIndices:function(){
292
 
                                var newRecords = [], index=0, oldRecord = [], a, b;
293
 
                                oldRecord = this.rs.getRecordsByIndex(index,2);
294
 
                                a = new Y.Record({data:{a:'newA', b:'newB', c:'newC'}});
295
 
                                b = new Y.Record({data:{a:'newD', b:'newE', c:'newF'}});
296
 
                                
297
 
                                newRecords.push(a);
298
 
                                newRecords.push(b);
299
 
                                
300
 
                                this.rs.on('update', function(e) {
301
 
                                        Y.ObjectAssert.areEqual(newRecords, e.updated, 'Updated record is != to new record');
302
 
                                        Y.ObjectAssert.areEqual(oldRecord, e.overwritten, 'Overwritten record is != to old record');
303
 
                                        Y.Assert.areEqual(2, e.overwritten.length, 'overwritten array is not of expected length');
304
 
                                        Y.Assert.areEqual(index, e.index, "correct index was modified");
305
 
                                });
306
 
                                
307
 
                                this.rs.update(newRecords, index);
308
 
                                
309
 
                                //check that the two elements in the recordset are the same as the ones pushed in
310
 
                                Y.ObjectAssert.areEqual(a.getValue(), this.rs.getRecordByIndex(0).getValue());
311
 
                                Y.ObjectAssert.areEqual(b.getValue(), this.rs.getRecordByIndex(1).getValue());
312
 
                                Y.ObjectAssert.areEqual(this.initialData[2], this.rs.getRecordByIndex(2).getValue());
313
 
                                
314
 
                                //3 initial records + 1 more added  (the other was just over-written)= 4 total records in recordset
315
 
                                Y.Assert.areEqual(3, this.rs.get('records').length);
316
 
                        },
317
 
                        
318
 
                        
319
 
                        
320
 
                        //---------------------------------------------
321
 
                    // Hashing in Base
322
 
                    //---------------------------------------------
323
 
 
324
 
                        testDefaultHash: function() {
325
 
                                
326
 
                                var hashTable = this.rs.get('table');
327
 
 
328
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(0).get('id')], this.rs.getRecordByIndex(0));
329
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(1).get('id')], this.rs.getRecordByIndex(1));
330
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(2).get('id')], this.rs.getRecordByIndex(2));
331
 
                                Y.Assert.areEqual(3, Y.Object.size(hashTable));
332
 
                                
333
 
                                //check hashtable sync when adding
334
 
                                this.rs.add({a:'hello', b:'hey', c:'yo!'});
335
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(0).get('id')], this.rs.getRecordByIndex(0));
336
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(1).get('id')], this.rs.getRecordByIndex(1));
337
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(2).get('id')], this.rs.getRecordByIndex(2));
338
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(3).get('id')], this.rs.getRecordByIndex(3));
339
 
                                Y.Assert.areEqual(4, Y.Object.size(hashTable));
340
 
                                
341
 
                                
342
 
                                //check hashtable sync when removing 1 object
343
 
                                this.rs.remove(1);
344
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(0).get('id')], this.rs.getRecordByIndex(0));
345
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(1).get('id')], this.rs.getRecordByIndex(1));
346
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(2).get('id')], this.rs.getRecordByIndex(2));
347
 
                                Y.Assert.areEqual(3, Y.Object.size(hashTable));
348
 
                                
349
 
                                //check hashtable sync when removing multiple records
350
 
                                this.rs.remove(0,2);
351
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(0).get('id')], this.rs.getRecordByIndex(0));
352
 
                                Y.Assert.areEqual(1, Y.Object.size(hashTable));
353
 
                                
354
 
                                
355
 
                                //update single record
356
 
                                this.rs.update({a:'new', b:'record', c:'added'}, 0);
357
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(0).get('id')], this.rs.getRecordByIndex(0));
358
 
                                //Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(1).get('id')], this.rs.getRecordByIndex(1));
359
 
                                
360
 
                                //Y.Assert.areEqual(2, Y.Object.size(hashTable));
361
 
                                Y.Assert.areEqual(1, Y.Object.size(hashTable));
362
 
                                
363
 
                                this.rs.update([
364
 
                    {a:'new', b:'record', c:'added'},
365
 
                    {a:'another', b:'new', c:'record'}
366
 
                ], 1);
367
 
 
368
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(0).get('id')], this.rs.getRecordByIndex(0));
369
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(1).get('id')], this.rs.getRecordByIndex(1));
370
 
                                Y.ObjectAssert.areEqual(hashTable[this.rs.getRecordByIndex(2).get('id')], this.rs.getRecordByIndex(2));
371
 
                                Y.Assert.areEqual(3, Y.Object.size(hashTable));
372
 
                        },
373
 
                        
374
 
                        
375
 
                        
376
 
                        
377
 
                        //---------------------------------------------
378
 
                    // Sort Plugin
379
 
                    //---------------------------------------------
380
 
                
381
 
                
382
 
                        //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
383
 
                        testDefaultSort: function() {
384
 
                                this.rs.plug(Y.Plugin.RecordsetSort);
385
 
 
386
 
                                //Test ascending order
387
 
                                Y.Assert.isFalse(this.rs.sort.get('isSorted'));
388
 
                                
389
 
                                
390
 
                                this.rs.sort.sort('a',false);
391
 
                                
392
 
                                Y.Assert.isTrue(this.rs.sort.get('isSorted'));
393
 
                                
394
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, this.rs.getRecordByIndex(0).getValue());
395
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, this.rs.getRecordByIndex(1).getValue());
396
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, this.rs.getRecordByIndex(2).getValue());
397
 
                                Y.Assert.areEqual(3, this.rs.getLength());
398
 
                                
399
 
                                
400
 
                                //Test Descending Order
401
 
                                this.rs.sort.sort('c',true);
402
 
                                Y.Assert.isTrue(this.rs.sort.get('isSorted'));
403
 
                                
404
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, this.rs.getRecordByIndex(0).getValue());
405
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, this.rs.getRecordByIndex(1).getValue());
406
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, this.rs.getRecordByIndex(2).getValue());
407
 
                                Y.Assert.areEqual(3, this.rs.getLength());
408
 
                                
409
 
                                
410
 
                                //Test sort when values are equal (sorts by ID)
411
 
                                this.rs.sort.sort('b',true);
412
 
                                Y.Assert.isTrue(this.rs.sort.get('isSorted'));
413
 
                                
414
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, this.rs.getRecordByIndex(0).getValue());
415
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, this.rs.getRecordByIndex(1).getValue());
416
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, this.rs.getRecordByIndex(2).getValue());
417
 
                                Y.Assert.areEqual(3, this.rs.getLength());
418
 
                                
419
 
                        },
420
 
                        
421
 
                        
422
 
                        //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}]
423
 
                        testResort: function() {
424
 
                                this.rs.plug(Y.Plugin.RecordsetSort);
425
 
                                
426
 
                                Y.Assert.isFalse(this.rs.sort.get('isSorted'));
427
 
                                
428
 
                                //Test ascending order
429
 
                                this.rs.sort.sort('a',false);
430
 
                                Y.Assert.isTrue(this.rs.sort.get('isSorted'));
431
 
                                
432
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, this.rs.getRecordByIndex(0).getValue());
433
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, this.rs.getRecordByIndex(1).getValue());
434
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, this.rs.getRecordByIndex(2).getValue());
435
 
                                Y.Assert.areEqual(3, this.rs.getLength());
436
 
                                
437
 
                                //Add another record to the end of the recordset
438
 
                                this.rs.add({a:6,b:5,c:8});
439
 
                                Y.Assert.isFalse(this.rs.sort.get('isSorted'));
440
 
                                
441
 
                                Y.ObjectAssert.areEqual({a:6,b:5,c:8}, this.rs.getRecordByIndex(3).getValue());
442
 
                                
443
 
                                //Refresh Sorter
444
 
                                this.rs.sort.resort();
445
 
                                Y.Assert.isTrue(this.rs.sort.get('isSorted'));
446
 
                                
447
 
                                //make sure the added record was sorted into the recordset using the existing sort properties
448
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, this.rs.getRecordByIndex(0).getValue());
449
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, this.rs.getRecordByIndex(1).getValue());
450
 
                                Y.ObjectAssert.areEqual({a:6,b:5,c:8}, this.rs.getRecordByIndex(2).getValue());
451
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, this.rs.getRecordByIndex(3).getValue());
452
 
                                Y.Assert.areEqual(4, this.rs.getLength());
453
 
                        },
454
 
                        
455
 
                        //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}
456
 
                        testReverseBeforeSort: function() {
457
 
                                        a = {a:'a', b:'b', c:'c'},
458
 
                                        b = {a:'d', b:'e', c:'f'},
459
 
                                        c = {a:'g', b:'h', c:'i'},
460
 
                                        d = {a:'j', b:'k', c:'l'};
461
 
                                this.rs.plug(Y.Plugin.RecordsetSort);
462
 
                                
463
 
                                //adding in some records backwards to understand if reversing is working properly
464
 
                                this.rs.add([d,c,b,a]);
465
 
                                this.rs.sort.reverse();
466
 
                                
467
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, this.rs.getRecordByIndex(6).getValue());
468
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, this.rs.getRecordByIndex(5).getValue());
469
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, this.rs.getRecordByIndex(4).getValue());
470
 
                                
471
 
                                Y.ObjectAssert.areEqual(d, this.rs.getRecordByIndex(3).getValue());
472
 
                                Y.ObjectAssert.areEqual(c, this.rs.getRecordByIndex(2).getValue());
473
 
                                Y.ObjectAssert.areEqual(b, this.rs.getRecordByIndex(1).getValue());
474
 
                                Y.ObjectAssert.areEqual(a, this.rs.getRecordByIndex(0).getValue());
475
 
                                
476
 
                                Y.Assert.areEqual(7, this.rs.getLength());
477
 
                        },
478
 
                        
479
 
                        //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}
480
 
                        testFlipAfterSort: function() {
481
 
                                        a = {a:1, b:'b', c:'c'},
482
 
                                        b = {a:2, b:'e', c:'f'},
483
 
                                        c = {a:3, b:'h', c:'i'},
484
 
                                        d = {a:4, b:'k', c:'l'};
485
 
                                this.rs.plug(Y.Plugin.RecordsetSort);
486
 
                                
487
 
                                //adding in some records backwards to understand if reversing is working properly
488
 
                                this.rs.add([d,c,b,a]);
489
 
                                
490
 
                                this.rs.sort.sort('a',true);
491
 
                                this.rs.sort.flip();
492
 
                                
493
 
                                //1s
494
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, this.rs.getRecordByIndex(0).getValue());
495
 
                                Y.ObjectAssert.areEqual(a, this.rs.getRecordByIndex(1).getValue());
496
 
                                //2s                            
497
 
                                Y.ObjectAssert.areEqual(b, this.rs.getRecordByIndex(2).getValue());
498
 
                                //3s
499
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, this.rs.getRecordByIndex(3).getValue());
500
 
                                Y.ObjectAssert.areEqual(c, this.rs.getRecordByIndex(4).getValue());
501
 
                                Y.ObjectAssert.areEqual(d, this.rs.getRecordByIndex(5).getValue());
502
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, this.rs.getRecordByIndex(6).getValue());
503
 
                                
504
 
                                Y.Assert.areEqual(7, this.rs.getLength());
505
 
                        },
506
 
                        
507
 
                        //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
508
 
                        testCustomSort: function() {
509
 
                                
510
 
                        
511
 
                                var a = {a:1, b:1, c:4},
512
 
                                        b = {a:2, b:2, c:5},
513
 
                                        c = {a:3, b:2, c:4},
514
 
                                        d = {a:4, b:4, c:7},
515
 
                                //This is just a copy of Y.ArraySort.compare
516
 
                                        compare = function(a, b, desc) {
517
 
                                if(!Y.Lang.isValue(a)) {
518
 
                                    if(!Y.Lang.isValue(b)) {
519
 
                                        return 0;
520
 
                                    }
521
 
                                    else {
522
 
                                        return 1;
523
 
                                    }
524
 
                                }
525
 
                                else if(!Y.Lang.isValue(b)) {
526
 
                                    return -1;
527
 
                                }
528
 
 
529
 
                                if(Y.Lang.isString(a)) {
530
 
                                    a.toLowerCase();
531
 
                                }
532
 
                                if(Y.Lang.isString(b)) {
533
 
                                    b.toLowerCase();
534
 
                                }
535
 
                                if(a < b) {
536
 
                                    return (desc) ? 1 : -1;
537
 
                                }
538
 
                                else if (a > b) {
539
 
                                    return (desc) ? -1 : 1;
540
 
                                }
541
 
                                else {
542
 
                                    return 0;
543
 
                                }
544
 
                            },
545
 
                        
546
 
                        
547
 
                                //custom sort where if the values in the given fieldA are equal, the values in fieldB are checked
548
 
                                 customsort = function(recA, recB, field, desc) {
549
 
                        var first_sorted = compare(recA.getValue(field), recB.getValue(field), desc);
550
 
                        if(first_sorted === 0) {
551
 
                            var second_sorted = compare(recA.getValue('b'), recB.getValue('b'), desc);
552
 
                                                if (second_sorted === 0) {
553
 
                                                        return compare(recA.get("id"), recB.get("id"), desc);
554
 
                                                }
555
 
                                                else {
556
 
                                                        return second_sorted;
557
 
                                                }
558
 
                        }
559
 
                        else {
560
 
                            return first_sorted;
561
 
                        }
562
 
                    };
563
 
                                
564
 
                                this.rs.plug(Y.Plugin.RecordsetSort);
565
 
                                this.rs.add([a,b,c,d]);
566
 
                                this.rs.sort.sort('a',false,customsort);
567
 
 
568
 
                                
569
 
                                
570
 
                                //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
571
 
                                //when the numbers are equal - the object that was added later should be first
572
 
                                Y.ObjectAssert.areEqual({a:1, b:1, c:4}, this.rs.getRecordByIndex(0).getValue());
573
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, this.rs.getRecordByIndex(1).getValue());
574
 
                                Y.ObjectAssert.areEqual({a:2, b:2, c:5}, this.rs.getRecordByIndex(2).getValue());
575
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, this.rs.getRecordByIndex(3).getValue());
576
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:4}, this.rs.getRecordByIndex(4).getValue());
577
 
                                Y.ObjectAssert.areEqual({a:4, b:4, c:7}, this.rs.getRecordByIndex(5).getValue());
578
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, this.rs.getRecordByIndex(6).getValue());
579
 
 
580
 
                                Y.Assert.areEqual(7, this.rs.getLength());
581
 
                        },
582
 
                        
583
 
                        //---------------------------------------------
584
 
                    // ArrayList Methods
585
 
                    //---------------------------------------------
586
 
                        
587
 
 
588
 
                        
589
 
                        testSize: function() {
590
 
                                Y.Assert.areEqual(3, this.rs.getLength());
591
 
                        },
592
 
                        
593
 
                        //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
594
 
                        testEach: function() {
595
 
                                var i = 0, recs = [];
596
 
                                this.rs.each(function() {
597
 
                                        recs[i] = this.getValue();
598
 
                                        i++;
599
 
                                });
600
 
                                
601
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, recs[0]);
602
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, recs[1]);
603
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, recs[2]);
604
 
                                Y.Assert.areEqual(3, recs.length);
605
 
                        },
606
 
                        
607
 
                        testSome: function() {
608
 
                                var recs=[], i=0, v={};
609
 
                                
610
 
                                
611
 
                                this.rs.some(function() {
612
 
                                        v = this.getValue();
613
 
                                        
614
 
                                        if (v.a !== 1) {
615
 
                                                recs[i] = v;
616
 
                                                i++;
617
 
                                                return false;
618
 
                                        }
619
 
                                        else {
620
 
                                                return true;
621
 
                                        }
622
 
                                        
623
 
                                });
624
 
                                
625
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, recs[0]);
626
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, recs[1]);
627
 
                                Y.Assert.areEqual(2, recs.length);
628
 
                        },
629
 
                        
630
 
                        //---------------------------------------------
631
 
                    // Filter Plugin
632
 
                    //---------------------------------------------
633
 
                
634
 
                        testFilter: function() {
635
 
                                this.rs.plug(Y.Plugin.RecordsetFilter);
636
 
                                var validator = function(item) {
637
 
                                        if (item.getValue('b') === 2) {
638
 
                                                return true;
639
 
                                        }
640
 
                                        else {
641
 
                                                return false;
642
 
                                        }
643
 
                                },
644
 
                                        rs = this.rs.filter.filter(validator);
645
 
                                
646
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, rs.getRecordByIndex(0).getValue());
647
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, rs.getRecordByIndex(1).getValue());
648
 
                                Y.Assert.areEqual(2, rs.getLength());
649
 
                                
650
 
                                //test a filter that doesn't return anything from recordset
651
 
                                validator = function(item) {
652
 
                                        if (item.getValue('c') === 2) {
653
 
                                                return true;
654
 
                                        }
655
 
                                        else {
656
 
                                                return false;
657
 
                                        }
658
 
                                };
659
 
                                
660
 
                                rs = this.rs.filter.filter(validator);
661
 
                                Y.Assert.areEqual(0, rs.getLength());
662
 
                                
663
 
                                
664
 
                                //Test Filter with Key Value pair
665
 
                                rs = this.rs.filter.filter('b',2);
666
 
                                Y.ObjectAssert.areEqual({a:3, b:2, c:1}, rs.getRecordByIndex(0).getValue());
667
 
                                Y.ObjectAssert.areEqual({a:1, b:2, c:3}, rs.getRecordByIndex(1).getValue());
668
 
                                Y.Assert.areEqual(2, rs.getLength());
669
 
                                
670
 
                        },
671
 
                        
672
 
                        testReject: function() {
673
 
                                this.rs.plug(Y.Plugin.RecordsetFilter);
674
 
                                
675
 
                                var validator = function(item) {
676
 
                                        if (item.getValue('b') === 2) {
677
 
                                                return true;
678
 
                                        }
679
 
                                        else {
680
 
                                                return false;
681
 
                                        }
682
 
                                },
683
 
                                
684
 
                                        rs = this.rs.filter.reject(validator);
685
 
                                        
686
 
                                //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
687
 
                                Y.ObjectAssert.areEqual({a:9, b:8, c:7}, rs.getRecordByIndex(0).getValue());
688
 
                                Y.Assert.areEqual(1, rs.getLength());
689
 
                                
690
 
                                
691
 
                                //try it with a validator that always returns false
692
 
                                validator = function(item) {
693
 
                                        if (item.getValue('c') === 2) {
694
 
                                                return true;
695
 
                                        }
696
 
                                        else {
697
 
                                                return false;
698
 
                                        }
699
 
                                };
700
 
                                
701
 
                                rs = this.rs.filter.reject(validator);
702
 
                                Y.ObjectAssert.areEqual(this.rs.getRecordByIndex(0).getValue(), rs.getRecordByIndex(0).getValue());
703
 
                                Y.ObjectAssert.areEqual(this.rs.getRecordByIndex(1).getValue(), rs.getRecordByIndex(1).getValue());
704
 
                                Y.ObjectAssert.areEqual(this.rs.getRecordByIndex(2).getValue(), rs.getRecordByIndex(2).getValue());
705
 
                                
706
 
                                Y.Assert.areEqual(this.rs.getLength(), rs.getLength());
707
 
                                                                        
708
 
                        },
709
 
                        
710
 
                        
711
 
                        //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)
712
 
                        testMap: function() {
713
 
                                var f = function(item) {
714
 
                                        if (item.getValue('b') === 2) {
715
 
                                                return true;
716
 
                                        }
717
 
                                        else {
718
 
                                                return false;
719
 
                                        } 
720
 
                                },
721
 
                                        rs = Y.Array.map(this.rs.get('records'),f);
722
 
                                Y.Assert.areEqual(true, rs[0]);
723
 
                                Y.Assert.areEqual(false, rs[1]);
724
 
                                Y.Assert.areEqual(true, rs[2]);
725
 
                                Y.Assert.areEqual(3, rs.length);
726
 
                        },
727
 
                        
728
 
                        //---------------------------------------------
729
 
                    // Indexer Plugin
730
 
                    //---------------------------------------------
731
 
                        
732
 
                        //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
733
 
                        
734
 
                        testCustomHashTableInitialization: function() {
735
 
                                this.rs.plug(Y.Plugin.RecordsetIndexer);
736
 
                                
737
 
                                var hashA = this.rs.indexer.createTable('a');
738
 
                                var hashTables = this.rs.indexer.get('hashTables');
739
 
                                
740
 
                                //check hashA
741
 
                                Y.ObjectAssert.areEqual(hashA[3].getValue(), {a:3, b:2, c:1});
742
 
                                Y.ObjectAssert.areEqual(hashA[9].getValue(), {a:9, b:8, c:7});
743
 
                                Y.ObjectAssert.areEqual(hashA[1].getValue(), {a:1, b:2, c:3});
744
 
                                
745
 
                                //check main table (contains all the subtables)
746
 
                                Y.ObjectAssert.areEqual(hashTables.a[3].getValue(), {a:3, b:2, c:1});
747
 
                                Y.ObjectAssert.areEqual(hashTables.a[9].getValue(), {a:9, b:8, c:7});
748
 
                                Y.ObjectAssert.areEqual(hashTables.a[1].getValue(), {a:1, b:2, c:3});
749
 
                                
750
 
                                Y.ObjectAssert.areEqual(hashA, hashTables.a);
751
 
 
752
 
                                
753
 
                                
754
 
                                var hashB = this.rs.indexer.createTable('b');
755
 
                                
756
 
                                Y.ObjectAssert.areEqual(hashTables.b[2].getValue(), {a:1, b:2, c:3});
757
 
                                Y.ObjectAssert.areEqual(hashTables.b[8].getValue(), {a:9, b:8, c:7});
758
 
                                Y.ObjectAssert.areEqual(hashB[2].getValue(), {a:1, b:2, c:3});
759
 
                                Y.ObjectAssert.areEqual(hashB[8].getValue(), {a:9, b:8, c:7});
760
 
                                Y.ObjectAssert.areEqual(hashB, hashTables.b);
761
 
                                
762
 
                        },
763
 
                        
764
 
                        //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
765
 
                        testCustomHashTableAddingRecord: function() {
766
 
                                this.rs.plug(Y.Plugin.RecordsetIndexer);
767
 
                                
768
 
                                var hashA = this.rs.indexer.createTable('a'),
769
 
                                        hashC = this.rs.indexer.createTable('c'),
770
 
                                        hashTables = this.rs.indexer.get('hashTables');
771
 
                                
772
 
                                //add to the end
773
 
                                this.rs.add({a:'adding', b:'this', c:'record'});
774
 
                                
775
 
                                Y.ObjectAssert.areEqual(hashA[3].getValue(), {a:3, b:2, c:1});
776
 
                                Y.ObjectAssert.areEqual(hashA[9].getValue(), {a:9, b:8, c:7});
777
 
                                Y.ObjectAssert.areEqual(hashA[1].getValue(), {a:1, b:2, c:3});
778
 
                                Y.ObjectAssert.areEqual(hashA['adding'].getValue(), {a:'adding', b:'this', c:'record'});                                                
779
 
                                Y.Assert.areEqual(4, Y.Object.size(hashA));
780
 
                                Y.ObjectAssert.areEqual(hashA, hashTables.a);
781
 
                                
782
 
                                
783
 
                                Y.ObjectAssert.areEqual(hashC[1].getValue(), {a:3, b:2, c:1});
784
 
                                Y.ObjectAssert.areEqual(hashC[7].getValue(), {a:9, b:8, c:7});
785
 
                                Y.ObjectAssert.areEqual(hashC[3].getValue(), {a:1, b:2, c:3});
786
 
                                Y.ObjectAssert.areEqual(hashC['record'].getValue(), {a:'adding', b:'this', c:'record'});
787
 
                                Y.Assert.areEqual(4, Y.Object.size(hashC));
788
 
                                Y.ObjectAssert.areEqual(hashC, hashTables.c);
789
 
                                
790
 
                                
791
 
                                //adding record to a specific index
792
 
                                this.rs.add({a:'another', b:'new', c:'record'}, 0);
793
 
                                
794
 
                                Y.ObjectAssert.areEqual(hashA[3].getValue(), {a:3, b:2, c:1});
795
 
                                Y.ObjectAssert.areEqual(hashA[9].getValue(), {a:9, b:8, c:7});
796
 
                                Y.ObjectAssert.areEqual(hashA[1].getValue(), {a:1, b:2, c:3});
797
 
                                Y.ObjectAssert.areEqual(hashA['adding'].getValue(), {a:'adding', b:'this', c:'record'});                
798
 
                                Y.ObjectAssert.areEqual(hashA['another'].getValue(), {a:'another', b:'new', c:'record'});                                               
799
 
                                Y.Assert.areEqual(5, Y.Object.size(hashA));
800
 
                                Y.ObjectAssert.areEqual(hashA, hashTables.a);
801
 
                                
802
 
                                
803
 
                                //'record' will overwrite the previous added record.
804
 
                                Y.ObjectAssert.areEqual(hashC[1].getValue(), {a:3, b:2, c:1});
805
 
                                Y.ObjectAssert.areEqual(hashC[7].getValue(), {a:9, b:8, c:7});
806
 
                                Y.ObjectAssert.areEqual(hashC[3].getValue(), {a:1, b:2, c:3});
807
 
                                Y.ObjectAssert.areEqual(hashC['record'].getValue(), {a:'another', b:'new', c:'record'});
808
 
                                Y.Assert.areEqual(4, Y.Object.size(hashC));
809
 
                                Y.ObjectAssert.areEqual(hashC, hashTables.c);
810
 
                                
811
 
                                //adding multiple records
812
 
                                this.rs.add([{a:'blah', b:'bloo', c:'bleh'},{a:'heres', b:'another', c:'one'}]);
813
 
                                
814
 
                                Y.ObjectAssert.areEqual(hashA[3].getValue(), {a:3, b:2, c:1});
815
 
                                Y.ObjectAssert.areEqual(hashA[9].getValue(), {a:9, b:8, c:7});
816
 
                                Y.ObjectAssert.areEqual(hashA[1].getValue(), {a:1, b:2, c:3});
817
 
                                Y.ObjectAssert.areEqual(hashA['adding'].getValue(), {a:'adding', b:'this', c:'record'});                
818
 
                                Y.ObjectAssert.areEqual(hashA['another'].getValue(), {a:'another', b:'new', c:'record'});
819
 
                                Y.ObjectAssert.areEqual(hashA['blah'].getValue(), {a:'blah', b:'bloo', c:'bleh'});
820
 
                                Y.ObjectAssert.areEqual(hashA['heres'].getValue(), {a:'heres', b:'another', c:'one'});                                          
821
 
                                                                                
822
 
                                Y.Assert.areEqual(7, Y.Object.size(hashA));
823
 
                                Y.ObjectAssert.areEqual(hashA, hashTables.a);
824
 
                                
825
 
                                
826
 
                                //'record' will overwrite the previous added record.
827
 
                                Y.ObjectAssert.areEqual(hashC[1].getValue(), {a:3, b:2, c:1});
828
 
                                Y.ObjectAssert.areEqual(hashC[7].getValue(), {a:9, b:8, c:7});
829
 
                                Y.ObjectAssert.areEqual(hashC[3].getValue(), {a:1, b:2, c:3});
830
 
                                Y.ObjectAssert.areEqual(hashC['record'].getValue(), {a:'another', b:'new', c:'record'});
831
 
                                Y.ObjectAssert.areEqual(hashC['bleh'].getValue(), {a:'blah', b:'bloo', c:'bleh'});
832
 
                                Y.ObjectAssert.areEqual(hashC['one'].getValue(), {a:'heres', b:'another', c:'one'});
833
 
                                Y.Assert.areEqual(6, Y.Object.size(hashC));
834
 
                                Y.ObjectAssert.areEqual(hashC, hashTables.c);
835
 
                                
836
 
                                
837
 
                        },                      
838
 
                        
839
 
                        testCustomHashTableRemovingRecord: function() {
840
 
                                this.rs.plug(Y.Plugin.RecordsetIndexer);
841
 
                                
842
 
                                var hashA = this.rs.indexer.createTable('a'),
843
 
                                        hashC = this.rs.indexer.createTable('c'),
844
 
                                        hashTables = this.rs.indexer.get('hashTables');
845
 
                                
846
 
                                this.rs.remove(2);
847
 
                                
848
 
                                
849
 
                                Y.ObjectAssert.areEqual(hashA[3].getValue(), {a:3, b:2, c:1});
850
 
                                Y.ObjectAssert.areEqual(hashA[9].getValue(), {a:9, b:8, c:7});                                          
851
 
                                Y.Assert.areEqual(2, Y.Object.size(hashA));
852
 
                                Y.ObjectAssert.areEqual(hashA, hashTables.a);
853
 
                                
854
 
                                //'record' will overwrite the previous added record.
855
 
                                Y.ObjectAssert.areEqual(hashC[1].getValue(), {a:3, b:2, c:1});
856
 
                                Y.ObjectAssert.areEqual(hashC[7].getValue(), {a:9, b:8, c:7});
857
 
                                Y.Assert.areEqual(2, Y.Object.size(hashC));
858
 
                                Y.ObjectAssert.areEqual(hashC, hashTables.c);
859
 
                                
860
 
                                
861
 
                                //try removing more than 1 record at a time
862
 
                                this.rs.add({a:1, b:2, c:3});
863
 
                                this.rs.remove(0,2);
864
 
                                
865
 
                                
866
 
                                Y.ObjectAssert.areEqual(hashA[1].getValue(), {a:1, b:2, c:3});
867
 
                                Y.Assert.areEqual(1, Y.Object.size(hashA));
868
 
                                Y.ObjectAssert.areEqual(hashA, hashTables.a);
869
 
                                
870
 
                                Y.ObjectAssert.areEqual(hashC[3].getValue(), {a:1, b:2, c:3});
871
 
                                Y.Assert.areEqual(1, Y.Object.size(hashC));
872
 
                                Y.ObjectAssert.areEqual(hashC, hashTables.c);
873
 
                        },
874
 
                        
875
 
                        
876
 
                                                //initialData: [{a:3, b:2, c:1}, {a:9, b:8, c:7}, {a:1, b:2, c:3}],
877
 
                                                
878
 
                        testCustomHashTableUpdatingRecord: function() {
879
 
                                this.rs.plug(Y.Plugin.RecordsetIndexer);
880
 
                                                        
881
 
                                var hashA = this.rs.indexer.createTable('a'),
882
 
                                        hashC = this.rs.indexer.createTable('c'),
883
 
                                        hashTables = this.rs.indexer.get('hashTables');
884
 
                                                        
885
 
                                this.rs.update({a:'one', b:'record', c:'added'}, 1);
886
 
                                                        
887
 
                                Y.ObjectAssert.areEqual(hashA[3].getValue(), {a:3, b:2, c:1});
888
 
                                Y.ObjectAssert.areEqual(hashA[1].getValue(), {a:1, b:2, c:3});
889
 
                                Y.ObjectAssert.areEqual(hashA['one'].getValue(), {a:'one', b:'record', c:'added'});             
890
 
                                Y.Assert.areEqual(3, Y.Object.size(hashA));
891
 
                                Y.ObjectAssert.areEqual(hashA, hashTables.a);
892
 
                                                
893
 
                                                
894
 
                                //'record' will overwrite the previous added record.
895
 
                                Y.ObjectAssert.areEqual(hashC[1].getValue(), {a:3, b:2, c:1});
896
 
                                Y.ObjectAssert.areEqual(hashC[3].getValue(), {a:1, b:2, c:3});
897
 
                                Y.ObjectAssert.areEqual(hashC['added'].getValue(), {a:'one', b:'record', c:'added'});
898
 
                                Y.Assert.areEqual(3, Y.Object.size(hashC));
899
 
                                Y.ObjectAssert.areEqual(hashC, hashTables.c);
900
 
                                        
901
 
                                //update multiple records
902
 
                                this.rs.update([{a:'adding', b:'this', c:'record'}, {a:'heres', b:'another', c:'one'}], 2);
903
 
                                                        
904
 
                                Y.ObjectAssert.areEqual(hashA[3].getValue(), {a:3, b:2, c:1});
905
 
                                Y.ObjectAssert.areEqual(hashA['adding'].getValue(), {a:'adding', b:'this', c:'record'});
906
 
                                Y.ObjectAssert.areEqual(hashA['heres'].getValue(), {a:'heres', b:'another', c:'one'});
907
 
                                Y.Assert.areEqual(4, Y.Object.size(hashA));
908
 
                                Y.ObjectAssert.areEqual(hashA, hashTables.a);
909
 
                                                        
910
 
                                                        
911
 
                                //'record' will overwrite the previous added record.
912
 
                                Y.ObjectAssert.areEqual(hashC[1].getValue(), {a:3, b:2, c:1});
913
 
                                Y.ObjectAssert.areEqual(hashC['record'].getValue(), {a:'adding', b:'this', c:'record'});
914
 
                                Y.ObjectAssert.areEqual(hashC['one'].getValue(), {a:'heres', b:'another', c:'one'});
915
 
                                Y.Assert.areEqual(4, Y.Object.size(hashC));
916
 
                                Y.ObjectAssert.areEqual(hashC, hashTables.c);
917
 
                                                        
918
 
                                                        
919
 
                        }
920
 
                        
921
 
                        
922
 
        });
923
 
 
924
 
        var suite = new Y.Test.Suite({name:"Recordset Test Suite"});
925
 
        suite.add(testBasic);
926
 
 
927
 
        Y.Test.Runner.setName("Recordset Test Runner");
928
 
        Y.Test.Runner.add(suite);
929
 
        Y.Test.Runner.run();
930
 
    });
931
 
})();
932
 
</script>
933
 
</body>
934
 
</html>