Browse Source

Added test for not fire "change" for same attribute value.

fredck 10 years ago
parent
commit
b14683f782
1 changed files with 16 additions and 0 deletions
  1. 16 0
      packages/ckeditor5-utils/tests/mvc/model/model.js

+ 16 - 0
packages/ckeditor5-utils/tests/mvc/model/model.js

@@ -112,6 +112,22 @@ describe( 'Model', function() {
 			sinon.assert.calledWithExactly( spyYear, sinon.match.instanceOf( EventInfo ), 2003, 2015 );
 			sinon.assert.calledWithExactly( spyWheels, sinon.match.instanceOf( EventInfo ), 4, sinon.match.typeOf( 'undefined' ) );
 		} );
+
+		it( 'should not fire "change" for same attribute value', function() {
+			var spy = sinon.spy();
+			var spyColor = sinon.spy();
+
+			car.on( 'change', spy );
+			car.on( 'change:color', spyColor );
+
+			// Set property in all possible ways.
+			car.color = 'red';
+			car.set( 'color', 'red' );
+			car.set( { color: 'red' } );
+
+			sinon.assert.notCalled( spy );
+			sinon.assert.notCalled( spyColor );
+		} );
 	} );
 
 	describe( 'extend', function() {