8
0

tooltipview.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /**
  2. * @license Copyright (c) 2003-2017, 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. text = view.element.firstChild;
  11. } );
  12. describe( 'constructor()', () => {
  13. it( 'should create element from template', () => {
  14. expect( view.element.tagName ).to.equal( 'SPAN' );
  15. expect( view.element.classList.contains( 'ck-tooltip' ) ).to.be.true;
  16. expect( view.element.childNodes ).to.have.length( 1 );
  17. expect( text.tagName ).to.equal( 'SPAN' );
  18. expect( text.classList.contains( 'ck-tooltip__text' ) ).to.be.true;
  19. } );
  20. it( 'should set default #position', () => {
  21. expect( view.position ).to.equal( 's' );
  22. } );
  23. } );
  24. describe( 'DOM bindings', () => {
  25. beforeEach( () => {
  26. view.text = 'foo';
  27. } );
  28. describe( 'text content', () => {
  29. it( 'should react on view#text', () => {
  30. expect( text.textContent ).to.equal( 'foo' );
  31. view.text = 'baz';
  32. expect( text.textContent ).to.equal( 'baz' );
  33. } );
  34. } );
  35. describe( 'class', () => {
  36. it( 'should react on view#text', () => {
  37. expect( view.element.classList.contains( 'ck-hidden' ) ).to.be.false;
  38. view.text = '';
  39. expect( view.element.classList.contains( 'ck-hidden' ) ).to.be.true;
  40. } );
  41. it( 'should react on view#position', () => {
  42. expect( view.element.classList.contains( 'ck-tooltip_n' ) ).to.be.false;
  43. expect( view.element.classList.contains( 'ck-tooltip_s' ) ).to.be.true;
  44. view.position = 'n';
  45. expect( view.element.classList.contains( 'ck-tooltip_n' ) ).to.be.true;
  46. expect( view.element.classList.contains( 'ck-tooltip_s' ) ).to.be.false;
  47. } );
  48. } );
  49. } );
  50. } );