8
0

listitemview.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* globals Event */
  6. import ListItemView from '../../src/list/listitemview';
  7. describe( 'ListItemView', () => {
  8. let view;
  9. beforeEach( () => {
  10. view = new ListItemView();
  11. view.set( {
  12. style: 'foo',
  13. label: 'bar'
  14. } );
  15. return view.init();
  16. } );
  17. describe( 'constructor()', () => {
  18. it( 'creates element from template', () => {
  19. expect( view.element.classList.contains( 'ck-list__item' ) ).to.be.true;
  20. } );
  21. } );
  22. describe( 'DOM bindings', () => {
  23. describe( '"style" attribute', () => {
  24. it( 'reacts on view#style', () => {
  25. expect( view.element.attributes.getNamedItem( 'style' ).value ).to.equal( 'foo' );
  26. view.style = 'color: red';
  27. expect( view.element.attributes.getNamedItem( 'style' ).value ).to.equal( 'color: red' );
  28. } );
  29. } );
  30. describe( 'text content', () => {
  31. it( 'reacts on view#label', () => {
  32. expect( view.element.innerHTML ).to.equal( 'bar' );
  33. view.label = 'baz';
  34. expect( view.element.innerHTML ).to.equal( 'baz' );
  35. } );
  36. } );
  37. describe( 'view#execute event', () => {
  38. it( 'triggers view#execute event when "click" is fired in DOM', () => {
  39. const spy = sinon.spy();
  40. view.on( 'execute', spy );
  41. view.element.dispatchEvent( new Event( 'click' ) );
  42. expect( spy.calledOnce ).to.be.true;
  43. } );
  44. } );
  45. } );
  46. } );