|
@@ -35,32 +35,35 @@ describe( 'EnterObserver', () => {
|
|
|
viewDocument.on( 'enter', spy );
|
|
viewDocument.on( 'enter', spy );
|
|
|
|
|
|
|
|
viewDocument.fire( 'keydown', new DomEventData( viewDocument, getDomEvent(), {
|
|
viewDocument.fire( 'keydown', new DomEventData( viewDocument, getDomEvent(), {
|
|
|
- keyCode: getCode( 'enter' )
|
|
|
|
|
|
|
+ keyCode: getCode( 'enter' ),
|
|
|
|
|
+ shiftKey: false
|
|
|
} ) );
|
|
} ) );
|
|
|
|
|
|
|
|
expect( spy.calledOnce ).to.be.true;
|
|
expect( spy.calledOnce ).to.be.true;
|
|
|
|
|
+ expect( spy.firstCall.args[ 1 ].isSoft ).to.be.false;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'is not fired on keydown when keyCode does not match enter', () => {
|
|
|
|
|
|
|
+ it( 'detects whether shift was pressed along with the "enter" key', () => {
|
|
|
const spy = sinon.spy();
|
|
const spy = sinon.spy();
|
|
|
|
|
|
|
|
viewDocument.on( 'enter', spy );
|
|
viewDocument.on( 'enter', spy );
|
|
|
|
|
|
|
|
viewDocument.fire( 'keydown', new DomEventData( viewDocument, getDomEvent(), {
|
|
viewDocument.fire( 'keydown', new DomEventData( viewDocument, getDomEvent(), {
|
|
|
- keyCode: 1
|
|
|
|
|
|
|
+ keyCode: getCode( 'enter' ),
|
|
|
|
|
+ shiftKey: true
|
|
|
} ) );
|
|
} ) );
|
|
|
|
|
|
|
|
- expect( spy.calledOnce ).to.be.false;
|
|
|
|
|
|
|
+ expect( spy.calledOnce ).to.be.true;
|
|
|
|
|
+ expect( spy.firstCall.args[ 1 ].isSoft ).to.be.true;
|
|
|
} );
|
|
} );
|
|
|
|
|
|
|
|
- it( 'is not fired on keydown when shiftKey is truthy', () => {
|
|
|
|
|
|
|
+ it( 'is not fired on keydown when keyCode does not match enter', () => {
|
|
|
const spy = sinon.spy();
|
|
const spy = sinon.spy();
|
|
|
|
|
|
|
|
viewDocument.on( 'enter', spy );
|
|
viewDocument.on( 'enter', spy );
|
|
|
|
|
|
|
|
viewDocument.fire( 'keydown', new DomEventData( viewDocument, getDomEvent(), {
|
|
viewDocument.fire( 'keydown', new DomEventData( viewDocument, getDomEvent(), {
|
|
|
- keyCode: getCode( 'enter' ),
|
|
|
|
|
- shiftKey: true
|
|
|
|
|
|
|
+ keyCode: 1
|
|
|
} ) );
|
|
} ) );
|
|
|
|
|
|
|
|
expect( spy.calledOnce ).to.be.false;
|
|
expect( spy.calledOnce ).to.be.false;
|