| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- /**
- * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- /* globals Event */
- import ListItemView from '../../src/list/listitemview';
- describe( 'ListItemView', () => {
- let view;
- beforeEach( () => {
- view = new ListItemView();
- view.set( {
- style: 'foo',
- label: 'bar'
- } );
- return view.init();
- } );
- describe( 'constructor()', () => {
- it( 'creates element from template', () => {
- expect( view.element.classList.contains( 'ck-list__item' ) ).to.be.true;
- } );
- } );
- describe( 'DOM bindings', () => {
- describe( '"style" attribute', () => {
- it( 'reacts on view#style', () => {
- expect( view.element.attributes.getNamedItem( 'style' ).value ).to.equal( 'foo' );
- view.style = 'color: red';
- expect( view.element.attributes.getNamedItem( 'style' ).value ).to.equal( 'color: red' );
- } );
- } );
- describe( 'text content', () => {
- it( 'reacts on view#label', () => {
- expect( view.element.innerHTML ).to.equal( 'bar' );
- view.label = 'baz';
- expect( view.element.innerHTML ).to.equal( 'baz' );
- } );
- } );
- describe( 'tabindex', () => {
- it( 'is initially set ', () => {
- expect( view.element.attributes.tabindex.value ).to.equal( '-1' );
- } );
- it( 'reacts on view#tabindex', () => {
- view.tabindex = 3;
- expect( view.element.attributes.tabindex.value ).to.equal( '3' );
- } );
- } );
- describe( 'view#execute event', () => {
- it( 'triggers view#execute event when "click" is fired in DOM', () => {
- const spy = sinon.spy();
- view.on( 'execute', spy );
- view.element.dispatchEvent( new Event( 'click' ) );
- expect( spy.calledOnce ).to.be.true;
- } );
- } );
- } );
- describe( 'focus()', () => {
- it( 'focuses the item in DOM', () => {
- const spy = sinon.spy( view.element, 'focus' );
- view.focus();
- sinon.assert.calledOnce( spy );
- } );
- } );
- } );
|