| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- /**
- * @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- import TooltipView from '../../src/tooltip/tooltipview';
- describe( 'TooltipView', () => {
- let view, text;
- beforeEach( () => {
- view = new TooltipView();
- view.render();
- text = view.element.firstChild;
- } );
- describe( 'constructor()', () => {
- it( 'should create element from template', () => {
- expect( view.element.tagName ).to.equal( 'SPAN' );
- expect( view.element.classList.contains( 'ck' ) ).to.be.true;
- expect( view.element.classList.contains( 'ck-tooltip' ) ).to.be.true;
- expect( view.element.childNodes ).to.have.length( 1 );
- expect( text.tagName ).to.equal( 'SPAN' );
- expect( text.classList.contains( 'ck' ) ).to.be.true;
- expect( text.classList.contains( 'ck-tooltip__text' ) ).to.be.true;
- } );
- it( 'should set default #position', () => {
- expect( view.position ).to.equal( 's' );
- } );
- } );
- describe( 'DOM bindings', () => {
- beforeEach( () => {
- view.text = 'foo';
- } );
- describe( 'text content', () => {
- it( 'should react on view#text', () => {
- expect( text.textContent ).to.equal( 'foo' );
- view.text = 'baz';
- expect( text.textContent ).to.equal( 'baz' );
- } );
- } );
- describe( 'class', () => {
- it( 'should react on view#text', () => {
- expect( view.element.classList.contains( 'ck-hidden' ) ).to.be.false;
- view.text = '';
- expect( view.element.classList.contains( 'ck-hidden' ) ).to.be.true;
- } );
- it( 'should react on view#position', () => {
- expect( view.element.classList.contains( 'ck-tooltip_n' ) ).to.be.false;
- expect( view.element.classList.contains( 'ck-tooltip_s' ) ).to.be.true;
- view.position = 'n';
- expect( view.element.classList.contains( 'ck-tooltip_n' ) ).to.be.true;
- expect( view.element.classList.contains( 'ck-tooltip_s' ) ).to.be.false;
- } );
- } );
- } );
- } );
|