2 * @fileoverview Tests for stand-alone functions in dygraph-utils.js
4 * @author danvdk@gmail.com (Dan Vanderkam)
7 var UtilsTestCase
= TestCase("utils-tests");
9 UtilsTestCase
.prototype.testUpdate
= function() {
16 assertEquals(1, a
['a']);
17 assertEquals([1, 2, 3], a
['b']);
18 assertEquals({x
: 1, y
: 2}, a
['c']);
19 assertEquals({f
: 10, g
: 20}, a
['d']);
21 Dygraph
.update(a
, { c
: { x
: 2 } });
22 assertEquals({x
: 2}, a
['c']);
24 Dygraph
.update(a
, { d
: null });
25 assertEquals(null, a
['d']);
27 Dygraph
.update(a
, { a
: 10, b
: [1, 2] });
28 assertEquals(10, a
['a']);
29 assertEquals([1, 2], a
['b']);
30 assertEquals({x
: 2}, a
['c']);
31 assertEquals(null, a
['d']);
34 UtilsTestCase
.prototype.testUpdateDeep
= function() {
41 assertEquals(1, a
['a']);
42 assertEquals([1, 2, 3], a
['b']);
43 assertEquals({x
: 1, y
: 2}, a
['c']);
44 assertEquals({f
: 10, g
: 20}, a
['d']);
46 Dygraph
.updateDeep(a
, { c
: { x
: 2 } });
47 assertEquals({x
: 2, y
: 2}, a
['c']);
49 Dygraph
.updateDeep(a
, { d
: null });
50 assertEquals(null, a
['d']);
52 Dygraph
.updateDeep(a
, { a
: 10, b
: [1, 2] });
53 assertEquals(10, a
['a']);
54 assertEquals([1, 2], a
['b']);
55 assertEquals({x
: 2, y
: 2}, a
['c']);
56 assertEquals(null, a
['d']);
59 UtilsTestCase
.prototype.testUpdateDeepDecoupled
= function() {
63 c
: { x
: "original", y
: 2},
67 Dygraph
.updateDeep(b
, a
);
73 assertEquals(1, a
.b
[0]);
76 assertEquals("original", a
.c
.x
);