| OLD | NEW |
| (Empty) | |
| 1 describe('sk.object functions', |
| 2 function() { |
| 3 function testGetDelta() { |
| 4 var test = function(o, d, expected) { |
| 5 assert.deepEqual(sk.object.getDelta(o, d), expected); |
| 6 } |
| 7 test({}, {}, {}); |
| 8 test({a: "foo"}, {a: "foo"}, {}); |
| 9 var first = {}; // Ensure getDelta does not modify its arguments. |
| 10 test(first, {a: "foo"}, {}); |
| 11 assert.deepEqual(first, {}); |
| 12 var second = {}; // Ensure getDelta does not modify its arguments. |
| 13 test({a: "foo"}, second, {a: "foo"}); |
| 14 assert.deepEqual(second, {}); |
| 15 test({a: "foo"}, {a: "bar"}, {a: "foo"}); |
| 16 test({a: "foo", b: "bar"}, {a: true, c: "bar"}, {a: "foo", b: "bar"}); |
| 17 test(["one", 2, 3.0], [1, "2", 3], {'0': "one"}); |
| 18 test({a: undefined, b: NaN, c: null}, {a: true, b: true, c: true}, |
| 19 {a: undefined, b: NaN, c: null}); |
| 20 test({a: undefined, b: NaN, c: false}, {a: null, b: null, c: null}, |
| 21 {b: NaN, c: false}); |
| 22 var noop = function () {}; |
| 23 test({a: test, b: noop}, {a: test, b: function () {}}, {b: noop}); |
| 24 } |
| 25 |
| 26 function testApplyDelta() { |
| 27 var test = function(delta, o, expected) { |
| 28 assert.deepEqual(sk.object.applyDelta(delta, o), expected); |
| 29 } |
| 30 test({}, {}, {}); |
| 31 test({}, {a: "foo"}, {a: "foo"}); |
| 32 var first = {a: "bar"}; // Ensure applyDelta does not modify its argument
s. |
| 33 test(first, {a: "foo"}, {a: "bar"}); |
| 34 assert.deepEqual(first, {a: "bar"}); |
| 35 var second = {a: "bar"}; // Ensure applyDelta does not modify its argumen
ts. |
| 36 test({a: "foo"}, second, {a: "foo"}); |
| 37 assert.deepEqual(second, {a: "bar"}); |
| 38 test({a: "foo"}, {a: "bar", b: "baz"}, {a: "foo", b: "baz"}); |
| 39 test({a: "foo", b: "baz"}, {a: "bar"}, {a: "foo"}); |
| 40 test({a: "foo", b: "bar"}, {a: true, c: "bar"}, |
| 41 {a: "foo", c: "bar"}); |
| 42 test(["one"], [1, "2", 3], {'0': "one", '1': "2", '2': 3}); |
| 43 test({b: NaN, c: false}, {a: null, b: null, c: null}, |
| 44 {a: null, b: NaN, c: false}); |
| 45 } |
| 46 |
| 47 it('should be able get differences and apply differences', function() { |
| 48 testGetDelta(); |
| 49 testApplyDelta(); |
| 50 }); |
| 51 } |
| 52 ); |
| OLD | NEW |