tooltipview.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /**
  2. * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import TooltipView from '../../src/tooltip/tooltipview';
  6. describe( 'TooltipView', () => {
  7. let view, text;
  8. beforeEach( () => {
  9. view = new TooltipView();
  10. view.render();
  11. text = view.element.firstChild;
  12. } );
  13. describe( 'constructor()', () => {
  14. it( 'should create element from template', () => {
  15. expect( view.element.tagName ).to.equal( 'SPAN' );
  16. expect( view.element.classList.contains( 'ck-tooltip' ) ).to.be.true;
  17. expect( view.element.childNodes ).to.have.length( 1 );
  18. expect( text.tagName ).to.equal( 'SPAN' );
  19. expect( text.classList.contains( 'ck-tooltip__text' ) ).to.be.true;
  20. } );
  21. it( 'should set default #position', () => {
  22. expect( view.position ).to.equal( 's' );
  23. } );
  24. } );
  25. describe( 'DOM bindings', () => {
  26. beforeEach( () => {
  27. view.text = 'foo';
  28. } );
  29. describe( 'text content', () => {
  30. it( 'should react on view#text', () => {
  31. expect( text.textContent ).to.equal( 'foo' );
  32. view.text = 'baz';
  33. expect( text.textContent ).to.equal( 'baz' );
  34. } );
  35. } );
  36. describe( 'class', () => {
  37. it( 'should react on view#text', () => {
  38. expect( view.element.classList.contains( 'ck-hidden' ) ).to.be.false;
  39. view.text = '';
  40. expect( view.element.classList.contains( 'ck-hidden' ) ).to.be.true;
  41. } );
  42. it( 'should react on view#position', () => {
  43. expect( view.element.classList.contains( 'ck-tooltip_n' ) ).to.be.false;
  44. expect( view.element.classList.contains( 'ck-tooltip_s' ) ).to.be.true;
  45. view.position = 'n';
  46. expect( view.element.classList.contains( 'ck-tooltip_n' ) ).to.be.true;
  47. expect( view.element.classList.contains( 'ck-tooltip_s' ) ).to.be.false;
  48. } );
  49. } );
  50. } );
  51. } );