Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves Issue with DeSerialization of Date: #4696 #4706

Merged
merged 5 commits into from
Dec 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/mixins/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@
break;

case Date:
value = isNaN(value) ? String(value) : Number(value);
outValue = new Date(value);
break;

Expand Down
16 changes: 16 additions & 0 deletions test/unit/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@

})
});
test('testing for deserialization of date', function(done) {
var dateArr = [];
dateArr[0] = new Date();
dateArr[1] = String(dateArr[0].getTime()); //string timestamp
dateArr[2] = dateArr[0].getTime(); //number timestamp
dateArr[3] = dateArr[0].toString(); //full date
setTimeout(function(){
let ser = [];
ser[0] = window.XFoo.prototype._deserializeValue(dateArr[1], Date);
ser[1] = window.XFoo.prototype._deserializeValue(dateArr[2], Date);
ser[2] = window.XFoo.prototype._deserializeValue(dateArr[3], Date);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like there is no assertion for this line? Could you add one for it? Also the variable name ser seems cryptic to me. Would be better to use a longer name to improve readability

Copy link
Contributor Author

@ronak1009 ronak1009 Nov 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I am just storing the return values of the deserializeValue function. I have used them in assert statements below.
I took this approach so that assert statements becomes more readable.
I shall change the variable name ser to serializedValue which shall become more readable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't disagree with the separation of the serializedValue array and the assertions, but I meant that I don't see any reference to ser[2] in the assertions on the lines below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @ronak1009 could you rebase and update the variable names per this comment 😄

assert.equal(ser[0].getTime(), ser[1].getTime());
assert.equal(ser[0].toString(), dateArr[3]);
done();
});
});

});

Expand Down