Browse Source

Tests: added tests for core.treeModel.operation.Operation.

Szymon Cofalik 9 years ago
parent
commit
3586051395
1 changed files with 33 additions and 0 deletions
  1. 33 0
      packages/ckeditor5-engine/tests/treemodel/operation/operation.js

+ 33 - 0
packages/ckeditor5-engine/tests/treemodel/operation/operation.js

@@ -0,0 +1,33 @@
+/**
+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* bender-tags: treemodel, delta */
+
+'use strict';
+
+import Delta from '/ckeditor5/core/treemodel/delta/delta.js';
+import Operation from '/ckeditor5/core/treemodel/operation/operation.js';
+
+describe( 'Operation', () => {
+	it( 'should save its base version', () => {
+		let op = new Operation( 4 );
+
+		expect( op.baseVersion ).to.equal( 4 );
+	} );
+
+	it( 'should be correctly transformed to JSON', () => {
+		let delta = new Delta();
+		let opInDelta = new Operation( 0 );
+		delta.addOperation( opInDelta );
+
+		let opOutsideDelta = new Operation( 0 );
+
+		let parsedIn = JSON.parse( JSON.stringify( opInDelta ) );
+		let parsedOutside = JSON.parse( JSON.stringify( opOutsideDelta ) );
+
+		expect( parsedIn.delta ).to.equal( '[core.treeModel.Delta]' );
+		expect( parsedOutside.delta ).to.be.null;
+	} );
+} );