Skip to content

Commit

Permalink
UnixTime tests
Browse files Browse the repository at this point in the history
  • Loading branch information
amarzavery committed Apr 29, 2016
1 parent 54cfaac commit 63fee4f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe('nodejs', function () {
});

it('should put and get UnixTime date correctly', function (done) {
var d = new Date(2016, 3, 12, 17, 0, 0);
var d = new Date('2016-04-13T00:00:00.000Z');
testClient.intModel.putUnixTimeDate(d, function (error, result) {
should.not.exist(error);
testClient.intModel.getUnixTime(function (error, result) {
Expand Down Expand Up @@ -1915,7 +1915,7 @@ describe('nodejs', function () {
});

it('should work when path has a paramaeter in UnixTime format', function (done) {
testClient.paths.unixTimeUrl(new Date(2016, 3, 12, 17, 0, 0), function (error, result) {
testClient.paths.unixTimeUrl(new Date('2016-04-13T00:00:00.000Z'), function (error, result) {
should.not.exist(error);
done();
});
Expand Down
3 changes: 2 additions & 1 deletion ClientRuntimes/NodeJS/ms-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ var msrest = require('ms-rest');
## Serialization/Deserialization
Features
- Type checking
- (String, Number, Boolean, ByteArray, Date, DateTime, Enum, TimeSpan, DateTimeRfc1123, Object, Stream, Sequence, Dictionary, Composite, Uuid(as a string))
- (String, Number, Boolean, ByteArray, Base64Url, Date, DateTime, Enum, TimeSpan, DateTimeRfc1123, UnixTime, Object, Stream, Sequence, Dictionary, Composite, Uuid(as a string))
- Validation of specified constraints
- ExclusiveMaximum, ExclusiveMinimum, InclusiveMaximum, InclusiveMinimum, MaxItems, MaxLength, MinItems, MinLength, MultipleOf, Pattern, UniqueItems
- Flattening/Unflattening properties
- Default Values
- Model Properties marked as constant are set during serialization, irrespective of they being provided or not
- Required check (If a model or property is marked required and is not provided in the object then an error is thrown)
- Readonly check (If a model or property is marked readonly then it is not sent on the wire during, serialization)
- Serializing Constant values

- serialize an array of dictionary of primitive values
```javascript
Expand Down
1 change: 0 additions & 1 deletion ClientRuntimes/NodeJS/ms-rest/lib/serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ function dateToUnixTime(d) {
if (!d) {
return null;
}
// A Date can be converted to string in JSON-clone operations, so let's tolerate.
if (typeof d.valueOf() === 'string') {
d = new Date(d);
}
Expand Down
6 changes: 6 additions & 0 deletions ClientRuntimes/NodeJS/ms-rest/test/serializationTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ describe('msrest', function () {
serializedDateString.should.equal('+010000-01-01T11:59:59.000Z');
done();
});
it('should correctly serialize a Date object with max value and format UnixTime', function (done) {
mapper = { type : { name: 'UnixTime' } };
var serializedDate = msRest.serialize(mapper, new Date('9999-12-31T23:59:59-12:00'), 'dateTimeObj');
serializedDate.should.equal(253402343999);
done();
});
it('should correctly serialize a string in DateTimeRfc1123', function (done) {
mapper = { type : { name: 'DateTimeRfc1123' } };
var rfc = new Date('Mon, 01 Jan 0001 00:00:00 GMT');
Expand Down

0 comments on commit 63fee4f

Please sign in to comment.