mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge branch 'deserialization-date'
This commit is contained in:
@@ -384,6 +384,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
break;
|
||||
|
||||
case Date:
|
||||
value = isNaN(value) ? String(value) : Number(value);
|
||||
outValue = new Date(value);
|
||||
break;
|
||||
|
||||
|
||||
@@ -113,6 +113,29 @@ suite('property-accessors', function() {
|
||||
});
|
||||
});
|
||||
|
||||
suite('testing for deserialization of date', function() {
|
||||
let date;
|
||||
|
||||
setup(function() {
|
||||
date = new Date();
|
||||
});
|
||||
|
||||
test('can handle string timestamp', function() {
|
||||
const deserializedDate = window.XFoo.prototype._deserializeValue(String(date.getTime()), Date);
|
||||
assert.equal(deserializedDate.getTime(), date.getTime());
|
||||
});
|
||||
|
||||
test('can handle number timestamp', function() {
|
||||
const deserializedDate = window.XFoo.prototype._deserializeValue(date.getTime(), Date);
|
||||
assert.equal(deserializedDate.getTime(), date.getTime());
|
||||
});
|
||||
|
||||
test('can handle full date', function() {
|
||||
const deserializedDate = window.XFoo.prototype._deserializeValue(date.toString(), Date);
|
||||
assert.equal(deserializedDate.toString(), date.toString());
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user