Adding test of timestamp's ms precision. (#1561)

* Adding test of timestamp's ms precision.
This commit is contained in:
Kenneth Geisshirt 2017-12-20 14:19:42 +01:00 committed by GitHub
parent 34ea280492
commit 839d8563a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -453,5 +453,25 @@ module.exports = {
TestCase.assertEqual(realm.objects('Date')[2].currentDate.getTime(), 1000000000000);
TestCase.assertEqual(realm.objects('Date')[3].currentDate.getTime(), -1000000000000);
TestCase.assertEqual(realm.objects('Date')[4].currentDate.toString(), stringifiedDate.toString());
},
testDateResolution: function() {
const dateObjectSchema = {
name: 'DateObject',
properties: {
dateCol: 'date'
}
}
var realm = new Realm({schema: [dateObjectSchema]})
realm.write(function() {
realm.create('DateObject', { dateCol: new Date('2017-12-07T20:16:03.837Z') })
})
var objects = realm.objects('DateObject')
TestCase.assertEqual(new Date('2017-12-07T20:16:03.837Z').getTime(), objects[0].dateCol.getTime())
TestCase.assertTrue(new Date('2017-12-07T20:16:03.837Z').toISOString() === objects[0].dateCol.toISOString())
realm.close()
}
};