Skip to content

Commit

Permalink
feat(message): add metadata schema path
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Feb 25, 2020
1 parent f7c1f8c commit 407349f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/message.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,23 @@ const MessageSchema = new Schema(
},
},

/**
* @name metadata
* @description Application specific additional information for the message.
* @type {Object}
* @since 0.18.0
* @version 1.0.0
* @instance
*/
metadata: {
type: Mixed,
fake: {
generator: 'helpers',
type: 'createTransaction',
},
},

// template: String|Predefine, //template used for sending
// metadata: Mixed, //extra message data
},
SCHEMA_OPTIONS
);
Expand Down
12 changes: 12 additions & 0 deletions test/unit/message.schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,16 @@ describe('Message Schema', () => {
expect(options.options.type.name).to.be.equal('Mixed');
expect(options.options.fake).to.exist;
});

it('should have metadata field', function() {
const metadata = Message.path('metadata');

expect(metadata).to.exist;
expect(metadata).to.be.an.instanceof(SchemaTypes.Mixed);
expect(metadata.instance).to.be.equal('Mixed');
expect(metadata).to.be.an('object');
expect(metadata.options.type).to.be.a('function');
expect(metadata.options.type.name).to.be.equal('Mixed');
expect(metadata.options.fake).to.exist;
});
});

0 comments on commit 407349f

Please sign in to comment.