Skip to content

Commit

Permalink
EZP-24065: added a setSection method to ContentMetadataUpdateStruct
Browse files Browse the repository at this point in the history
  • Loading branch information
dpobel committed Mar 17, 2015
1 parent 2baa4ae commit c20464a
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/structures/ContentMetadataUpdateStruct.js
Expand Up @@ -18,5 +18,15 @@ define(function () {
};
};

/**
* Sets the section id
*
* @method setSection
* @param {String} sectionId the Section REST id
*/
ContentMetadataUpdateStruct.prototype.setSection = function (sectionId) {
this.body.ContentUpdate.Section = {_href: sectionId};
};

return ContentMetadataUpdateStruct;
});
37 changes: 37 additions & 0 deletions test/ContentMetadataUpdateStruct.tests.js
@@ -0,0 +1,37 @@
/* global define, describe, it, expect, beforeEach */
define(function (require) {
var ContentMetadataUpdateStruct = require('structures/ContentMetadataUpdateStruct');

describe('ContentMetadataUpdateStruct', function () {
var contentMetadataUpdateStruct;

beforeEach(function () {
contentMetadataUpdateStruct = new ContentMetadataUpdateStruct();
});

describe('constructor', function () {
it('should initialize the body', function () {
expect(contentMetadataUpdateStruct.body).toEqual({'ContentUpdate': {}});
});

it('should set the headers', function () {
expect(contentMetadataUpdateStruct.headers).toEqual({
"Accept": "application/vnd.ez.api.ContentInfo+json",
"Content-Type": "application/vnd.ez.api.ContentUpdate+json"
});
});
});

describe('setSection', function () {
it('should set the Section property', function () {
var sectionId = 'section-id';

contentMetadataUpdateStruct.setSection(sectionId);

expect(contentMetadataUpdateStruct.body.ContentUpdate.Section).toEqual({
_href: sectionId,
});
});
});
});
});

0 comments on commit c20464a

Please sign in to comment.