Răsfoiți Sursa

Tests: Basic tests for ui/region.

Aleksander Nowodzinski 10 ani în urmă
părinte
comite
aced1e00fc

+ 1 - 1
packages/ckeditor5-engine/src/ui/region.js

@@ -12,7 +12,7 @@
  * @extends Model
  */
 
-CKEDITOR.define( [ 'Collection', 'Model' ], function( Collection, Model ) {
+CKEDITOR.define( [ 'collection', 'model' ], function( Collection, Model ) {
 	class Region extends Model {
 		/**
 		 * Creates an instance of the {@link Region} class.

+ 52 - 0
packages/ckeditor5-engine/tests/ui/view/region.js

@@ -0,0 +1,52 @@
+/**
+ * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
+ * For licensing, see LICENSE.md.
+ */
+
+/* global document */
+/* bender-tags: core, ui */
+
+'use strict';
+
+var modules = bender.amd.require( 'ckeditor', 'ui/region', 'ui/view', 'collection' );
+
+describe( 'Region', function() {
+	var region;
+	var el;
+
+	beforeEach( 'Create a test region instance', function() {
+		var Region = modules[ 'ui/region' ];
+
+		el = document.createElement( 'div' );
+		region = new Region( 'foo', el );
+	} );
+
+	it( 'accepts constructor paramaters', function() {
+		expect( region ).to.have.property( 'name', 'foo' );
+		expect( region ).to.have.property( 'el', el );
+	} );
+
+	it( 'has views collection', function() {
+		var Collection = modules.collection;
+		expect( region.views ).to.be.an.instanceof( Collection );
+	} );
+
+	it( 'adds views to collection', function() {
+		var View = modules[ 'ui/view' ];
+
+		class TestView extends View {
+			constructor() {
+				super();
+				this.template = { tag: 'b' };
+			}
+		}
+
+		expect( region.el.childNodes.length ).to.be.equal( 0 );
+
+		region.views.add( new TestView() );
+		expect( region.el.childNodes.length ).to.be.equal( 1 );
+
+		region.views.add( new TestView() );
+		expect( region.el.childNodes.length ).to.be.equal( 2 );
+	} );
+} );