Skip to content

Commit

Permalink
feat: add campaign title or name
Browse files Browse the repository at this point in the history
  • Loading branch information
lykmapipo committed Jun 15, 2019
1 parent fbbda96 commit 9978954
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
21 changes: 20 additions & 1 deletion lib/campaign.model.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@ const CampaignSchema = new Schema({
fake: true
},

/**
* @name title
* @alias name
* @description title of the campaign i.e email title etc
* @type {Object}
* @since 0.1.0
* @version 1.0.0
* @instance
*/
title: {
type: String,
trim: true,
index: true,
searchable: true,
taggable: true,
fake: { generator: 'lorem', type: 'sentence' }
},

/**
* @name subject
* @description subject of the campaign i.e email title etc
Expand All @@ -87,7 +105,7 @@ const CampaignSchema = new Schema({
/**
* @name message
* @description content of the campaign to be conveyed to receiver(s) or
* recepient(s).
* recepient(s) as message body.
* @type {Object}
* @since 0.1.0
* @version 1.0.0
Expand All @@ -96,6 +114,7 @@ const CampaignSchema = new Schema({
message: {
type: String,
trim: true,
required: true,
index: true,
searchable: true,
fake: { generator: 'lorem', type: 'sentence' }
Expand Down
19 changes: 17 additions & 2 deletions test/unit/campaign.schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,22 @@ describe('Campaign Schema', () => {
expect(form.options.fake).to.exist;
});

it('should have subject field', function () {
it('should have title field', () => {
const title = Campaign.path('title');

expect(title).to.exist;
expect(title).to.be.an.instanceof(SchemaTypes.String);
expect(title.instance).to.be.equal('String');
expect(title).to.be.an('object');
expect(title.options.type).to.be.a('function');
expect(title.options.type.name).to.be.equal('String');
expect(title.options.trim).to.be.true;
expect(title.options.index).to.be.true;
expect(title.options.searchable).to.be.true;
expect(title.options.fake).to.exist;
});

it('should have subject field', () => {
const subject = Campaign.path('subject');

expect(subject).to.exist;
Expand All @@ -42,7 +57,7 @@ describe('Campaign Schema', () => {
expect(subject.options.fake).to.exist;
});

it('should have message field', function () {
it('should have message field', () => {
const message = Campaign.path('message');

expect(message).to.exist;
Expand Down

0 comments on commit 9978954

Please sign in to comment.