diff --git a/test/unit/property-accessors.html b/test/unit/property-accessors.html index 147cd643b3..f1fc70db79 100644 --- a/test/unit/property-accessors.html +++ b/test/unit/property-accessors.html @@ -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()); }); });