From 532e3a2be4a6deeb7e47dd1c4fa14c522cdc0576 Mon Sep 17 00:00:00 2001 From: Rafael Weinstein Date: Tue, 8 Jul 2014 20:24:19 -0700 Subject: [PATCH] add tests for computed properties with object indices R=arv BUG= Review URL: https://codereview.appspot.com/112860043 --- tests/tests.js | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/tests.js b/tests/tests.js index a455f34..2e417ec 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -1092,6 +1092,60 @@ suite('PolymerExpressions', function() { }); }); + test('computed property with object index', function(done) { + var div = createTestHtml( + ''); + + var model = { + myObj: { + 'Tue Jul 08 2014 12:00:00 GMT-0700 (PDT)': 'bar', + 'Wed Jul 09 2014 12:00:00 GMT-0700 (PDT)': 'baz' + }, + dateObj: new Date('Tue Jul 08 2014 12:00:00 GMT-0700 (PDT)') + }; + + recursivelySetTemplateModel(div, model); + + then(function() { + assert.equal('bar', div.childNodes[1].getAttribute('foo')); + model.dateObj = new Date('Wed Jul 09 2014 12:00:00 GMT-0700 (PDT)'); + + }).then(function() { + assert.equal('baz', div.childNodes[1].getAttribute('foo')); + + done(); + }); + }); + + test('computed property with object index - assignment', function(done) { + var div = createTestHtml( + ''); + + var model = { + myObj: { + 'Tue Jul 08 2014 12:00:00 GMT-0700 (PDT)': 'bar', + }, + dateObj: new Date('Tue Jul 08 2014 12:00:00 GMT-0700 (PDT)') + }; + + recursivelySetTemplateModel(div, model); + + then(function() { + assert.equal('bar', div.childNodes[1].value); + div.childNodes[1].value = 'baz'; + dispatchEvent('input', div.childNodes[1]); + + }).then(function() { + assert.equal('baz', + model.myObj['Tue Jul 08 2014 12:00:00 GMT-0700 (PDT)']); + done(); + }); + }); + test('two-way computed property', function(done) { var div = createTestHtml( '