Skip to content

Commit

Permalink
Remove dead code; add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Sep 4, 2015
1 parent b221dbe commit ab85884
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/standard/notify-path.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 8 additions & 2 deletions test/unit/notify-path-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -219,7 +222,10 @@
arrayOrPropChanged: function(prop, splices) {
this.observerCounts.arrayOrPropChanged++;
assert.equal(prop, this.prop);
}
},
aChanged: function() {},
bChanged: function() {},
cChanged: function() {}
});
</script>
</dom-module>
57 changes: 57 additions & 0 deletions test/unit/notify-path.html
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

});

</script>
Expand Down

0 comments on commit ab85884

Please sign in to comment.