Skip to content

Commit

Permalink
feat: account created getter
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-scherzinger committed Feb 7, 2017
1 parent c77f28f commit 9d7b577
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/resources/AccountResource.js
Expand Up @@ -6,6 +6,15 @@ import Resource from './Resource';
* @class
*/
export default class AccountResource extends Resource {
/**
* Will return created property.
*
* @returns {Date} the create date.
*/
getCreated() {
return new Date(this.getProperty('created'));
}

/**
* Will return accountID property.
*
Expand Down
18 changes: 17 additions & 1 deletion test/Account.test.js
Expand Up @@ -283,7 +283,7 @@ describe('Account Resource', () => {
resource.should.be.instanceOf(Resource);
});
it('should be instance of AccountResource', () => {
resource.should.be.instanceOf(Resource);
resource.should.be.instanceOf(AccountResource);
});
it('should return boolean on hasPendingEmail', () => {
resource.hasPendingEmail().should.be.false;
Expand All @@ -304,6 +304,22 @@ describe('Account Resource', () => {
resource.getAllPermissions().should.have.property('length', 8);
});

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 getter = ['accountID', 'name', 'email', 'groups', 'language', 'state', 'openID', 'permissions'];
getter.forEach((name) => {
it(`should call resource.getProperty with ${name}`, () => {
Expand Down

0 comments on commit 9d7b577

Please sign in to comment.