|
|
@ -26,6 +26,7 @@ describe('DataSet', function () { |
|
|
|
]); |
|
|
|
|
|
|
|
var items = data.get(); |
|
|
|
assert.equal(data.length, 4); |
|
|
|
assert.equal(items.length, 4); |
|
|
|
items.forEach(function (item) { |
|
|
|
assert.ok(item.start instanceof Date); |
|
|
@ -76,6 +77,7 @@ describe('DataSet', function () { |
|
|
|
{id: 3}, |
|
|
|
{id: 4} |
|
|
|
]); |
|
|
|
assert.equal(data.length, 3); |
|
|
|
|
|
|
|
// add an item
|
|
|
|
data.add({id: 5, content: 'Item 5', start: now.valueOf()}); |
|
|
@ -87,12 +89,17 @@ describe('DataSet', function () { |
|
|
|
{id: 4}, |
|
|
|
{id: 5} |
|
|
|
]); |
|
|
|
assert.equal(data.length, 4); |
|
|
|
|
|
|
|
// update an item
|
|
|
|
data.update({id: 5, content: 'changed!'}); // update item (extend existing fields)
|
|
|
|
assert.equal(data.length, 4); |
|
|
|
data.remove(3); // remove existing item
|
|
|
|
assert.equal(data.length, 3); |
|
|
|
data.add({id: 3, other: 'bla'}); // add new item
|
|
|
|
assert.equal(data.length, 4); |
|
|
|
data.update({id: 6, content: 'created!', start: now.valueOf()}); // this item is not yet existing, create it
|
|
|
|
assert.equal(data.length, 5); |
|
|
|
assert.deepEqual(data.get().sort(sort), [ |
|
|
|
{id: 1, content: 'Item 1', start: now}, |
|
|
|
{id: 3, other: 'bla'}, |
|
|
@ -100,8 +107,10 @@ describe('DataSet', function () { |
|
|
|
{id: 5, content: 'changed!', start: now}, |
|
|
|
{id: 6, content: 'created!', start: now} |
|
|
|
]); |
|
|
|
assert.equal(data.length, 5); |
|
|
|
|
|
|
|
data.clear(); |
|
|
|
assert.equal(data.length, 0); |
|
|
|
|
|
|
|
assert.equal(data.get().length, 0); |
|
|
|
|
|
|
|