region.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global document */
  6. /* bender-tags: core, ui */
  7. 'use strict';
  8. var modules = bender.amd.require( 'ckeditor', 'ui/region', 'ui/view', 'collection' );
  9. describe( 'Region', function() {
  10. var region;
  11. var el;
  12. beforeEach( 'Create a test region instance', function() {
  13. var Region = modules[ 'ui/region' ];
  14. el = document.createElement( 'div' );
  15. region = new Region( 'foo', el );
  16. } );
  17. it( 'accepts constructor paramaters', function() {
  18. expect( region ).to.have.property( 'name', 'foo' );
  19. expect( region ).to.have.property( 'el', el );
  20. } );
  21. it( 'has views collection', function() {
  22. var Collection = modules.collection;
  23. expect( region.views ).to.be.an.instanceof( Collection );
  24. } );
  25. it( 'adds views to collection', function() {
  26. var View = modules[ 'ui/view' ];
  27. class TestView extends View {
  28. constructor() {
  29. super();
  30. this.template = { tag: 'b' };
  31. }
  32. }
  33. expect( region.el.childNodes.length ).to.be.equal( 0 );
  34. region.views.add( new TestView() );
  35. expect( region.el.childNodes.length ).to.be.equal( 1 );
  36. region.views.add( new TestView() );
  37. expect( region.el.childNodes.length ).to.be.equal( 2 );
  38. } );
  39. } );