Skip to content

Commit

Permalink
feat: datamanager created getter
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-scherzinger committed Feb 7, 2017
1 parent 9d7b577 commit 2f4efcf
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/resources/DataManagerResource.js
Expand Up @@ -6,6 +6,16 @@ import Resource from './Resource';
* @class
*/
export default class DataManagerResource extends Resource {

/**
* Will return created property.
*
* @returns {Date} the create date.
*/
getCreated() {
return new Date(this.getProperty('created'));
}

/**
* Set a new value to title property.
* @param {string} value the value to assign.
Expand Down
16 changes: 16 additions & 0 deletions test/DataManager.test.js
Expand Up @@ -162,6 +162,22 @@ describe('DataManager Resource', () => {
resource.should.be.instanceOf(DataManagerResource);
});

const dateGetter = [
'created',
];
dateGetter.forEach((name) => {
it(`should call resource.getProperty with ${name}`, () => {
const spy = sinon.spy(resource, 'getProperty');

const property = resource[`get${capitalizeFirstLetter(name)}`]();
spy.should.have.been.called.once;
spy.should.have.been.calledWith(name);
property.toISOString().should.be.equal(resource.getProperty(name));

spy.restore();
});
});

const functions = ['title', 'description', 'config', 'hexColor', 'locales'];
functions.forEach((name) => {
it(`should call resource.getProperty with ${name}`, () => {
Expand Down

0 comments on commit 2f4efcf

Please sign in to comment.