@@ -13,7 +13,7 @@ import ClassicEditorUIView from '../src/classiceditoruiview';
1313import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor' ;
1414
1515import FocusTracker from '@ckeditor/ckeditor5-utils/src/focustracker' ;
16- import { keyCodes } from '@ckeditor/ckeditor5-utils /src/keyboard ' ;
16+ import * as enableToolbarKeyboardFocus from '@ckeditor/ckeditor5-ui /src/toolbar/enabletoolbarkeyboardfocus ' ;
1717
1818import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils' ;
1919import utils from '@ckeditor/ckeditor5-utils/tests/_utils/utils' ;
@@ -139,69 +139,22 @@ describe( 'ClassicEditorUI', () => {
139139 } ) ;
140140
141141 it ( 'fills view.toolbar#items with editor config' , ( ) => {
142+ const spy = testUtils . sinon . spy ( view . toolbar , 'fillFromConfig' ) ;
143+
142144 return ui . init ( ) . then ( ( ) => {
143- expect ( view . toolbar . items ) . to . have . length ( 2 ) ;
144- expect ( view . toolbar . items . get ( 0 ) . name ) . to . equal ( 'foo' ) ;
145- expect ( view . toolbar . items . get ( 1 ) . name ) . to . equal ( 'bar' ) ;
145+ sinon . assert . calledWithExactly ( spy , editor . config . get ( 'toolbar' ) , ui . componentFactory ) ;
146146 } ) ;
147147 } ) ;
148148
149- describe ( 'activates keyboard navigation for the toolbar' , ( ) => {
150- it ( 'Alt+F10: focus the first focusable toolbar item' , ( ) => {
151- return ui . init ( ) . then ( ( ) => {
152- const spy = sinon . spy ( view . toolbar , 'focus' ) ;
153- const toolbarFocusTracker = view . toolbar . focusTracker ;
154- const keyEvtData = {
155- keyCode : keyCodes . f10 ,
156- altKey : true ,
157- preventDefault : sinon . spy ( ) ,
158- stopPropagation : sinon . spy ( )
159- } ;
160-
161- toolbarFocusTracker . isFocused = false ;
162- ui . focusTracker . isFocused = false ;
163-
164- editor . keystrokes . press ( keyEvtData ) ;
165- sinon . assert . notCalled ( spy ) ;
166-
167- toolbarFocusTracker . isFocused = true ;
168- ui . focusTracker . isFocused = true ;
169-
170- editor . keystrokes . press ( keyEvtData ) ;
171- sinon . assert . notCalled ( spy ) ;
172-
173- toolbarFocusTracker . isFocused = false ;
174- ui . focusTracker . isFocused = true ;
175-
176- editor . keystrokes . press ( keyEvtData ) ;
177- sinon . assert . calledOnce ( spy ) ;
178-
179- sinon . assert . calledOnce ( keyEvtData . preventDefault ) ;
180- sinon . assert . calledOnce ( keyEvtData . stopPropagation ) ;
181- } ) ;
182- } ) ;
183-
184- it ( 'esc: re–foucus editable when toolbar is focused' , ( ) => {
185- return ui . init ( ) . then ( ( ) => {
186- const spy = sinon . spy ( editor . editing . view , 'focus' ) ;
187- const toolbarFocusTracker = view . toolbar . focusTracker ;
188- const keyEvtData = { keyCode : keyCodes . esc ,
189- preventDefault : sinon . spy ( ) ,
190- stopPropagation : sinon . spy ( )
191- } ;
192-
193- toolbarFocusTracker . isFocused = false ;
194-
195- ui . view . toolbar . keystrokes . press ( keyEvtData ) ;
196- sinon . assert . notCalled ( spy ) ;
149+ it ( 'initializes keyboard navigation between view#toolbar and view#editable' , ( ) => {
150+ const spy = testUtils . sinon . spy ( enableToolbarKeyboardFocus , 'default' ) ;
197151
198- toolbarFocusTracker . isFocused = true ;
199-
200- ui . view . toolbar . keystrokes . press ( keyEvtData ) ;
201-
202- sinon . assert . calledOnce ( spy ) ;
203- sinon . assert . calledOnce ( keyEvtData . preventDefault ) ;
204- sinon . assert . calledOnce ( keyEvtData . stopPropagation ) ;
152+ return ui . init ( ) . then ( ( ) => {
153+ sinon . assert . calledWithExactly ( spy , {
154+ origin : editor . editing . view ,
155+ originFocusTracker : ui . focusTracker ,
156+ originKeystrokeHandler : editor . keystrokes ,
157+ toolbar : view . toolbar
205158 } ) ;
206159 } ) ;
207160 } ) ;
0 commit comments