Skip to content
Permalink
Browse files

Merge branch 't/12896' into major

  • Loading branch information...
Reinmar committed Feb 18, 2015
2 parents 3bf82bb + ca313af commit 5bf89890f728af37d8375ea5fb5a5ea155752f43
Showing with 26 additions and 20 deletions.
  1. +1 −2 plugins/notificationaggregator/plugin.js
  2. +25 −18 tests/plugins/notificationaggregator/aggregator.js
@@ -273,7 +273,6 @@
_getNotificationMessage: function() {
var tasksCount = this.getTasksCount(),
doneTasks = this.getDoneTasksCount(),
remainingTasks = tasksCount - doneTasks,
templateParams = {
current: doneTasks,
max: tasksCount,
@@ -282,7 +281,7 @@
template;

// If there's only one remaining task and we have a singular message, we should use it.
if ( remainingTasks == 1 && this._singularMessage ) {
if ( tasksCount == 1 && this._singularMessage ) {
template = this._singularMessage;
} else {
template = this._message;
@@ -369,37 +369,44 @@
} );
},

// When only single task is remaining and special message was defined,
// we should use special singular message.
// When there is only one task and singular message was defined,
// we should use the singular message.
'test _getNotificationMessage single': function() {
var instance = new Aggregator( this.editor, '' );
var instance = new Aggregator( this.editor, 'foo' );
instance._singularMessage = {
output: sinon.stub().returns( 'bar' )
};
instance.getTasksCount = sinon.stub().returns( 2 );
instance.getDoneTasksCount = sinon.stub().returns( 1 );
instance.getPercentage = sinon.stub().returns( 0.5 );
instance.getTasksCount = sinon.stub().returns( 1 );
instance.getDoneTasksCount = sinon.stub().returns( 0 );
instance.getPercentage = sinon.stub().returns( 0.2 );

assert.areSame( 'bar', instance._getNotificationMessage() );
sinon.assert.calledWithExactly( instance._singularMessage.output, {
current: 1,
max: 2,
percentage: 50
current: 0,
max: 1,
percentage: 20
} );
},

// Ensure that if only one task is remaining, BUT NO SPECIAL MESSAGE was
// defined for singular case, the standard message is used.
'test _getNotificationMessage missing singular': function() {
var instance = new Aggregator( this.editor, '' );
instance._message = {
output: sinon.stub().returns( 'bar' )
};
// When only a single task remained and singular message was defined,
// we should still use the plural message.
'test _getNotificationMessage plural message even if single message defined': function() {
var instance = new Aggregator( this.editor, 'foo', 'bar' );

instance.getTasksCount = sinon.stub().returns( 2 );
instance.getDoneTasksCount = sinon.stub().returns( 1 );
instance.getPercentage = sinon.stub().returns( 50 );

assert.areSame( 'bar', instance._getNotificationMessage() );
assert.areSame( 'foo', instance._getNotificationMessage() );
},

// When there is only one task, BUT NO SINGULAR MESSAGE was
// defined, the standard message is used.
'test _getNotificationMessage missing singular': function() {
var instance = new Aggregator( this.editor, 'foo' );
instance.getTasksCount = sinon.stub().returns( 1 );
instance.getDoneTasksCount = sinon.stub().returns( 0 );

assert.areSame( 'foo', instance._getNotificationMessage() );
},

'test _createNotification': function() {

0 comments on commit 5bf8989

Please sign in to comment.
You can’t perform that action at this time.