|
@@ -6,7 +6,6 @@
|
|
|
/* globals document */
|
|
/* globals document */
|
|
|
|
|
|
|
|
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
|
|
import Collection from '@ckeditor/ckeditor5-utils/src/collection';
|
|
|
-import utilsTestUtils from '@ckeditor/ckeditor5-utils/tests/_utils/utils';
|
|
|
|
|
|
|
|
|
|
import Model from '../../src/model';
|
|
import Model from '../../src/model';
|
|
|
|
|
|
|
@@ -14,19 +13,15 @@ import ButtonView from '../../src/button/buttonview';
|
|
|
import ToolbarView from '../../src/toolbar/toolbarview';
|
|
import ToolbarView from '../../src/toolbar/toolbarview';
|
|
|
import ListItemView from '../../src/list/listitemview';
|
|
import ListItemView from '../../src/list/listitemview';
|
|
|
import ListView from '../../src/list/listview';
|
|
import ListView from '../../src/list/listview';
|
|
|
-import DropdownView from '../../src/dropdown/dropdownview';
|
|
|
|
|
-import DropdownPanelView from '../../src/dropdown/dropdownpanelview';
|
|
|
|
|
import createButtonForDropdown from '../../src/dropdown/helpers/createbuttonfordropdown';
|
|
import createButtonForDropdown from '../../src/dropdown/helpers/createbuttonfordropdown';
|
|
|
|
|
+import createDropdownView from '../../src/dropdown/helpers/createdropdownview';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
addListViewToDropdown,
|
|
addListViewToDropdown,
|
|
|
addToolbarToDropdown,
|
|
addToolbarToDropdown,
|
|
|
- createDropdownView,
|
|
|
|
|
enableModelIfOneIsEnabled
|
|
enableModelIfOneIsEnabled
|
|
|
} from '../../src/dropdown/utils';
|
|
} from '../../src/dropdown/utils';
|
|
|
|
|
|
|
|
-const assertBinding = utilsTestUtils.assertBinding;
|
|
|
|
|
-
|
|
|
|
|
describe( 'utils', () => {
|
|
describe( 'utils', () => {
|
|
|
let dropdownView, buttonView, model, locale;
|
|
let dropdownView, buttonView, model, locale;
|
|
|
|
|
|
|
@@ -43,109 +38,6 @@ describe( 'utils', () => {
|
|
|
}
|
|
}
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- describe( 'createDropdownView()', () => {
|
|
|
|
|
- it( 'returns view', () => {
|
|
|
|
|
- model = new Model();
|
|
|
|
|
- buttonView = new ButtonView();
|
|
|
|
|
- dropdownView = createDropdownView( model, buttonView, locale );
|
|
|
|
|
-
|
|
|
|
|
- expect( dropdownView ).to.be.instanceOf( DropdownView );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'creates dropdown#panelView out of DropdownPanelView', () => {
|
|
|
|
|
- model = new Model();
|
|
|
|
|
- buttonView = new ButtonView();
|
|
|
|
|
- dropdownView = createDropdownView( model, buttonView, locale );
|
|
|
|
|
-
|
|
|
|
|
- expect( dropdownView.panelView ).to.be.instanceOf( DropdownPanelView );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'creates dropdown#buttonView out of buttonView', () => {
|
|
|
|
|
- model = new Model();
|
|
|
|
|
- buttonView = new ButtonView();
|
|
|
|
|
- dropdownView = createDropdownView( model, buttonView, locale );
|
|
|
|
|
-
|
|
|
|
|
- expect( dropdownView.buttonView ).to.equal( buttonView );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'accepts locale', () => {
|
|
|
|
|
- const buttonView = new ButtonView();
|
|
|
|
|
- dropdownView = createDropdownView( model, buttonView, locale );
|
|
|
|
|
-
|
|
|
|
|
- expect( dropdownView.locale ).to.equal( locale );
|
|
|
|
|
- expect( dropdownView.panelView.locale ).to.equal( locale );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'binds button attributes to the model', () => {
|
|
|
|
|
- const modelDef = {
|
|
|
|
|
- label: 'foo',
|
|
|
|
|
- isOn: false,
|
|
|
|
|
- isEnabled: true,
|
|
|
|
|
- withText: false,
|
|
|
|
|
- tooltip: false
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- model = new Model( modelDef );
|
|
|
|
|
- buttonView = new ButtonView();
|
|
|
|
|
- createDropdownView( model, buttonView, locale );
|
|
|
|
|
-
|
|
|
|
|
- assertBinding( buttonView,
|
|
|
|
|
- modelDef,
|
|
|
|
|
- [
|
|
|
|
|
- [ model, { label: 'bar', isEnabled: false, isOn: true, withText: true, tooltip: true } ]
|
|
|
|
|
- ],
|
|
|
|
|
- { label: 'bar', isEnabled: false, isOn: true, withText: true, tooltip: true }
|
|
|
|
|
- );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'binds button#isOn do dropdown #isOpen and model #isOn', () => {
|
|
|
|
|
- const modelDef = {
|
|
|
|
|
- label: 'foo',
|
|
|
|
|
- isOn: false,
|
|
|
|
|
- isEnabled: true,
|
|
|
|
|
- withText: false,
|
|
|
|
|
- tooltip: false
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- model = new Model( modelDef );
|
|
|
|
|
- buttonView = new ButtonView();
|
|
|
|
|
- dropdownView = createDropdownView( model, buttonView, locale );
|
|
|
|
|
-
|
|
|
|
|
- dropdownView.isOpen = false;
|
|
|
|
|
- expect( buttonView.isOn ).to.be.false;
|
|
|
|
|
-
|
|
|
|
|
- model.isOn = true;
|
|
|
|
|
- expect( buttonView.isOn ).to.be.true;
|
|
|
|
|
-
|
|
|
|
|
- dropdownView.isOpen = true;
|
|
|
|
|
- expect( buttonView.isOn ).to.be.true;
|
|
|
|
|
-
|
|
|
|
|
- model.isOn = false;
|
|
|
|
|
- expect( buttonView.isOn ).to.be.true;
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
- it( 'binds dropdown#isEnabled to the model', () => {
|
|
|
|
|
- const modelDef = {
|
|
|
|
|
- label: 'foo',
|
|
|
|
|
- isEnabled: true,
|
|
|
|
|
- withText: false,
|
|
|
|
|
- tooltip: false
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- model = new Model( modelDef );
|
|
|
|
|
- buttonView = new ButtonView();
|
|
|
|
|
- dropdownView = createDropdownView( model, buttonView, locale );
|
|
|
|
|
-
|
|
|
|
|
- assertBinding( dropdownView,
|
|
|
|
|
- { isEnabled: true },
|
|
|
|
|
- [
|
|
|
|
|
- [ model, { isEnabled: false } ]
|
|
|
|
|
- ],
|
|
|
|
|
- { isEnabled: false }
|
|
|
|
|
- );
|
|
|
|
|
- } );
|
|
|
|
|
- } );
|
|
|
|
|
-
|
|
|
|
|
describe( 'enableModelIfOneIsEnabled()', () => {
|
|
describe( 'enableModelIfOneIsEnabled()', () => {
|
|
|
it( 'Bind to #isEnabled of each observable and set it true if any observable #isEnabled is true', () => {
|
|
it( 'Bind to #isEnabled of each observable and set it true if any observable #isEnabled is true', () => {
|
|
|
const observables = [
|
|
const observables = [
|