Added some more tests around RecordedEvent properties type

This commit is contained in:
Nicolas Dextraze
2019-11-01 12:57:54 -07:00
parent 67dab18d53
commit 6ad2d34114
4 changed files with 18 additions and 10 deletions

View File

@ -49,6 +49,7 @@ const EventReadStatus = Object.freeze({
* @property {string} eventId
* @property {Long} eventNumber
* @property {string} eventType
* @property {Date} created
* @property {number} createdEpoch
* @property {?Buffer} data
* @property {?Buffer} metadata
@ -61,8 +62,8 @@ function RecordedEvent(ev) {
this.eventType = ev.eventType;
this.created = new Date(ev.createdEpoch ? ev.createdEpoch.toNumber() : 0);
this.createdEpoch = ev.createdEpoch ? ev.createdEpoch.toNumber() : 0;
this.data = ev.data ? ev.data : new Buffer(0);
this.metadata = ev.metadata ? ev.metadata : new Buffer(0);
this.data = ev.data ? ev.data : Buffer.alloc(0);
this.metadata = ev.metadata ? ev.metadata : Buffer.alloc(0);
this.isJson = ev.dataContentType === 1;
Object.freeze(this);
}
@ -268,4 +269,4 @@ exports.PersistentSubscriptionCreateStatus = PersistentSubscriptionCreateStatus;
exports.PersistentSubscriptionUpdateResult = PersistentSubscriptionUpdateResult;
exports.PersistentSubscriptionUpdateStatus = PersistentSubscriptionUpdateStatus;
exports.PersistentSubscriptionDeleteResult = PersistentSubscriptionDeleteResult;
exports.PersistentSubscriptionDeleteStatus = PersistentSubscriptionDeleteStatus;
exports.PersistentSubscriptionDeleteStatus = PersistentSubscriptionDeleteStatus;