Skip to content

Commit

Permalink
Added tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
niegowski committed Apr 22, 2024
1 parent 80f599e commit b3de933
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/ckeditor5-engine/tests/view/observer/focusobserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,46 @@ describe( 'FocusObserver', () => {

expect( viewDocument.isFocused ).to.be.false;
} );

it( 'should set isFocused to true on beforeinput after 50ms', () => {
expect( viewDocument.isFocused ).to.be.false;

observer.onDomEvent( { type: 'beforeinput', target: domMain } );
expect( viewDocument.isFocused ).to.be.false;

clock.tick( 50 );
expect( viewDocument.isFocused ).to.be.true;
} );

it( 'should set isFocused to true on beforeinput after flush', () => {
expect( viewDocument.isFocused ).to.be.false;

observer.onDomEvent( { type: 'beforeinput', target: domMain } );
expect( viewDocument.isFocused ).to.be.false;

observer.flush();
expect( viewDocument.isFocused ).to.be.true;
} );

it( 'should not set isFocused to true on beforeinput on other element after 50ms', () => {
expect( viewDocument.isFocused ).to.be.false;

observer.onDomEvent( { type: 'beforeinput', target: document } );
expect( viewDocument.isFocused ).to.be.false;

clock.tick( 50 );
expect( viewDocument.isFocused ).to.be.true;
} );

it( 'should not set isFocused to true on beforeinput on focused document after 50ms', () => {
viewDocument.isFocused = true;

observer.onDomEvent( { type: 'beforeinput', target: document } );
expect( viewDocument.isFocused ).to.be.true;

clock.tick( 50 );
expect( viewDocument.isFocused ).to.be.true;
} );
} );

describe( 'handle _isFocusChanging property of the document', () => {
Expand Down

0 comments on commit b3de933

Please sign in to comment.