Skip to content

Commit

Permalink
Merge pull request #76 from fvn-linagora/AddMailboxQuotas
Browse files Browse the repository at this point in the history
adding property 'quotas' to 'Mailbox'
  • Loading branch information
fvn-linagora committed Mar 13, 2018
2 parents 5bbf33c + 6db37ef commit a27f91d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## [master]

## [0.0.27] - 2018-03-12
### Added
- add 'quota' property to 'Mailbox' #74

## [0.0.26] - 2018-03-08
### Added
- add properties 'MDNSent' and 'MDNNotSent' to 'SetResponse' for read receipt notifications #72

### Changed
- main entry point is now located in dist folder.

## [0.0.25] - 2017-10-10
### Added
- Add 'namespace' and 'sharedWith' property to Mailbox. Fixes #69
Expand Down
5 changes: 4 additions & 1 deletion lib/models/Mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export default class Mailbox extends Model {
* @param [opts.unreadMessages=0] {Number} The number of messages in this mailbox with _isUnread_=true and _isDraft_=false.
* @param [opts.totalThreads=0] {Number} The number of threads where at least one message in the thread is in this mailbox.
* @param [opts.unreadThreads=0] {Number} The number of threads where at least one message in the thread is in this mailbox with _isUnread_=true and _isDraft_=false.
*
* @param [opts.quotas={}] {Object} List of enforced quotas. 'STORAGE' for size quota and 'MESSAGE' for messages count. Each one provide used and max properties.
used (Number) number of messages, or size in bytes for storage
max (Number|null) maximum number of messages, or maximum size in bytes for storage. Null means unlimited
* @see Model
*/
constructor(jmap, id, name, opts) {
Expand Down Expand Up @@ -60,6 +62,7 @@ export default class Mailbox extends Model {
this.unreadMessages = opts.unreadMessages || 0;
this.totalThreads = opts.totalThreads || 0;
this.unreadThreads = opts.unreadThreads || 0;
this.quotas = opts.quotas || {};
}

/**
Expand Down
7 changes: 6 additions & 1 deletion test/common/models/Mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('The Mailbox class', function() {
expect(mailbox.unreadMessages).to.equal(0);
expect(mailbox.totalThreads).to.equal(0);
expect(mailbox.unreadThreads).to.equal(0);
expect(mailbox.quotas).to.deep.equal({});
});

it('should use default values for all other fields if an empty opts object is given', function() {
Expand All @@ -59,6 +60,7 @@ describe('The Mailbox class', function() {
expect(mailbox.unreadMessages).to.equal(0);
expect(mailbox.totalThreads).to.equal(0);
expect(mailbox.unreadThreads).to.equal(0);
expect(mailbox.quotas).to.deep.equal({});
});

it('should allow defining optional properties through the opts object', function() {
Expand Down Expand Up @@ -144,6 +146,7 @@ describe('The Mailbox class', function() {
expect(mailbox.unreadMessages).to.equal(0);
expect(mailbox.totalThreads).to.equal(0);
expect(mailbox.unreadThreads).to.equal(0);
expect(mailbox.quotas).to.deep.equal({});
});

it('should copy values for id, name, and all other fields if defined', function() {
Expand All @@ -167,7 +170,8 @@ describe('The Mailbox class', function() {
totalMessages: 123,
unreadMessages: 4,
totalThreads: 567,
unreadThreads: 8
unreadThreads: 8,
quotas: { '#private&user': { STORAGE: { used: 10, max: 512 }, MESSAGE: { used: 42, max: null } } }
});

expect(mailbox.id).to.equal('id');
Expand All @@ -188,6 +192,7 @@ describe('The Mailbox class', function() {
expect(mailbox.unreadMessages).to.equal(4);
expect(mailbox.totalThreads).to.equal(567);
expect(mailbox.unreadThreads).to.equal(8);
expect(mailbox.quotas).to.deep.equal({ '#private&user': { STORAGE: { used: 10, max: 512 }, MESSAGE: { used: 42, max: null } } });
});

});
Expand Down

0 comments on commit a27f91d

Please sign in to comment.