From ab858844115f8246aa43930e4e2ffb1ca3c9e1e9 Mon Sep 17 00:00:00 2001 From: Kevin Schaaf Date: Thu, 3 Sep 2015 21:36:44 -0700 Subject: [PATCH] Remove dead code; add tests. --- src/standard/notify-path.html | 1 - test/unit/notify-path-elements.html | 10 ++++- test/unit/notify-path.html | 57 +++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/src/standard/notify-path.html b/src/standard/notify-path.html index 9fd0d3c20e..8875cf5df5 100644 --- a/src/standard/notify-path.html +++ b/src/standard/notify-path.html @@ -299,7 +299,6 @@ }, _notifyBoundPaths: function(path, value) { - var from, to; for (var a in this._boundPaths) { var b = this._boundPaths[a]; if (path.indexOf(a + '.') == 0) { diff --git a/test/unit/notify-path-elements.html b/test/unit/notify-path-elements.html index 2d386d01d5..4afbae4a85 100644 --- a/test/unit/notify-path-elements.html +++ b/test/unit/notify-path-elements.html @@ -125,7 +125,10 @@ 'multiplePathsChanged(a, nested.b, nested.obj.c)', 'arrayChanged(array.splices)', 'arrayNoCollChanged(arrayNoColl.splices)', - 'arrayOrPropChanged(prop, array.splices)' + 'arrayOrPropChanged(prop, array.splices)', + 'aChanged(a.*)', + 'bChanged(b.*)', + 'cChanged(c.*)' ], created: function() { this.observerCounts = { @@ -219,7 +222,10 @@ arrayOrPropChanged: function(prop, splices) { this.observerCounts.arrayOrPropChanged++; assert.equal(prop, this.prop); - } + }, + aChanged: function() {}, + bChanged: function() {}, + cChanged: function() {} }); \ No newline at end of file diff --git a/test/unit/notify-path.html b/test/unit/notify-path.html index e4d266bb1e..e84cb1124e 100644 --- a/test/unit/notify-path.html +++ b/test/unit/notify-path.html @@ -1153,6 +1153,63 @@ assert.strictEqual(el.array[3], 'orig3'); }); + test('link two objects', function() { + var aChanged = 0; + var bChanged = 0; + el.a = el.b = {}; + el.linkPaths('b', 'a'); + el.aChanged = function() { aChanged++; }; + el.bChanged = function() { bChanged++; }; + el.set('a.foo', 1); + assert.equal(aChanged, 1); + assert.equal(bChanged, 1); + }); + + test('link three objects', function() { + var aChanged = 0; + var bChanged = 0; + var cChanged = 0; + el.a = el.b = el.c = {}; + el.linkPaths('b', 'a'); + el.linkPaths('c', 'a'); + el.aChanged = function() { aChanged++; }; + el.bChanged = function() { bChanged++; }; + el.cChanged = function() { cChanged++; }; + el.set('a.foo', 1); + assert.equal(aChanged, 1); + assert.equal(bChanged, 1); + assert.equal(cChanged, 1); + }); + + test('link two arrays', function() { + var aChanged = 0; + var bChanged = 0; + el.a = el.b = []; + el.linkPaths('b', 'a'); + el.aChanged = function() { aChanged++; }; + el.bChanged = function() { bChanged++; }; + el.set('a.foo', 1); + assert.equal(aChanged, 1); + assert.equal(bChanged, 1); + }); + + test('link three arrays', function() { + var aChanged = 0; + var bChanged = 0; + var cChanged = 0; + el.a = el.b = el.c = []; + el.linkPaths('b', 'a'); + el.linkPaths('c', 'a'); + el.aChanged = function() { aChanged++; }; + el.bChanged = function() { bChanged++; }; + el.cChanged = function() { cChanged++; }; + el.push('a', {}); + // 2 changes for arrays (splices & length) + assert.equal(aChanged, 2); + assert.equal(bChanged, 2); + assert.equal(cChanged, 2); + }); + });