Skip to content

Commit

Permalink
Update test to be more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
TimvdLippe committed Dec 3, 2017
1 parent 939ce63 commit 86a64b6
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions test/unit/property-accessors.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,27 @@

})
});
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);
assert.equal(ser[0].getTime(), ser[1].getTime());
assert.equal(ser[0].toString(), dateArr[3]);
done();

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());
});
});

Expand Down

1 comment on commit 86a64b6

@ronak1009
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks @TimvdLippe

Please sign in to comment.