Skip to content

Commit

Permalink
Add unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Jul 17, 2015
1 parent f8cad94 commit bc4b142
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions test/unit/notify-path.html
Original file line number Diff line number Diff line change
Expand Up @@ -841,6 +841,66 @@
assert.equal(el.get('nested.again.again.wayOverThere'), 99);
});

test('get array', function() {
el.arrayChanged = function() {};
el.array = [1, 2, 3];
el.array.array = [5, 6, 7];
el.array.prop = 'prop';
assert.equal(el.get('array'), el.array);
assert.equal(el.get('array.0'), 1);
assert.equal(el.get('array.1'), 2);
assert.equal(el.get('array.2'), 3);
assert.equal(el.get('array.array'), el.array.array);
assert.equal(el.get('array.array.0'), 5);
assert.equal(el.get('array.array.1'), 6);
assert.equal(el.get('array.array.2'), 7);
assert.equal(el.get('array.prop'), 'prop');
el.unshift('array', 0);
el.splice('array', 2, 0, 1.5);
el.unshift('array.array', 4);
el.splice('array.array', 2, 0, 5.5);
assert.equal(el.get('array.0'), 0);
assert.equal(el.get('array.1'), 1);
assert.equal(el.get('array.2'), 1.5);
assert.equal(el.get('array.3'), 2);
assert.equal(el.get('array.4'), 3);
assert.equal(el.get('array.array.0'), 4);
assert.equal(el.get('array.array.1'), 5);
assert.equal(el.get('array.array.2'), 5.5);
assert.equal(el.get('array.array.3'), 6);
assert.equal(el.get('array.array.4'), 7);
});

test('set array', function() {
el.arrayChanged = function() {};
el.set('array', [1, 2, 3]);
el.set('array.array', [5, 6, 7]);
el.set('array.prop', 'prop');
assert.equal(el.get('array'), el.array);
assert.equal(el.get('array.0'), 1);
assert.equal(el.get('array.1'), 2);
assert.equal(el.get('array.2'), 3);
assert.equal(el.get('array.array'), el.array.array);
assert.equal(el.get('array.array.0'), 5);
assert.equal(el.get('array.array.1'), 6);
assert.equal(el.get('array.array.2'), 7);
assert.equal(el.get('array.prop'), 'prop');
el.set(['array', 0], 81);
el.set(['array', 1], 82);
el.set(['array', 2], 83);
el.set(['array.array', 0], 91);
el.set(['array.array', 1], 92);
el.set(['array.array', 2], 93);
el.set('array.prop', 'foo');
assert.equal(el.get('array.0'), 81);
assert.equal(el.get('array.1'), 82);
assert.equal(el.get('array.2'), 83);
assert.equal(el.get('array.array.0'), 91);
assert.equal(el.get('array.array.1'), 92);
assert.equal(el.get('array.array.2'), 93);
assert.equal(el.get('array.prop'), 'foo');
});

});

</script>
Expand Down

0 comments on commit bc4b142

Please sign in to comment.