@@ -753,7 +753,7 @@ QUnit.module('Options', moduleConfig, () => {
753753
754754QUnit . module ( 'Component Lifecycle' , moduleConfig , ( ) => {
755755 QUnit . test ( 'should properly initialize actions with noop fallback' , function ( assert ) {
756- const expectedActions = [ 'onStartClick' , 'onStopClick' , 'onResult' , 'onError' ] ;
756+ const expectedActions = [ 'onStartClick' , 'onStopClick' , 'onResult' , 'onError' , 'onEnd' ] ;
757757
758758 expectedActions . forEach ( action => {
759759 assert . notStrictEqual ( this . instance . _actions [ action ] , undefined , `${ action } action initialized` ) ;
@@ -869,6 +869,7 @@ QUnit.module('SpeechRecognitionAdapter integration', moduleConfig, () => {
869869 const actionsSpies = {
870870 onResult : sinon . spy ( ) ,
871871 onError : sinon . spy ( ) ,
872+ onEnd : sinon . spy ( ) ,
872873 } ;
873874
874875 this . reinit ( actionsSpies ) ;
@@ -878,6 +879,7 @@ QUnit.module('SpeechRecognitionAdapter integration', moduleConfig, () => {
878879 const actions = [
879880 { option : 'onResult' , method : 'onresult' , spy : actionsSpies . onResult , event : { type : 'result' } } ,
880881 { option : 'onError' , method : 'onerror' , spy : actionsSpies . onError , event : { type : 'error' } } ,
882+ { option : 'onEnd' , method : 'onend' , spy : actionsSpies . onEnd , event : { type : 'end' } } ,
881883 ] ;
882884
883885 actions . forEach ( ( { option, method, spy, event } ) => {
@@ -953,14 +955,16 @@ QUnit.module('SpeechRecognitionAdapter integration', moduleConfig, () => {
953955 assert . strictEqual ( this . getSpeechRecognition ( ) . lang , 'fr-FR' , 'config updated in recognition instance' ) ;
954956 } ) ;
955957
956- QUnit . test ( 'should update onResult/onError handlers at runtime' , function ( assert ) {
958+ QUnit . test ( 'should update onResult/onError/onEnd handlers at runtime' , function ( assert ) {
957959 const initialActionsSpies = {
958960 onResult : sinon . spy ( ) ,
959961 onError : sinon . spy ( ) ,
962+ onEnd : sinon . spy ( ) ,
960963 } ;
961964 const updatedActionsSpies = {
962965 onResult : sinon . spy ( ) ,
963966 onError : sinon . spy ( ) ,
967+ onEnd : sinon . spy ( ) ,
964968 } ;
965969
966970 this . reinit ( initialActionsSpies ) ;
@@ -970,6 +974,8 @@ QUnit.module('SpeechRecognitionAdapter integration', moduleConfig, () => {
970974 const actions = [
971975 { prop : 'onresult' , option : 'onResult' , initial : initialActionsSpies . onResult , updated : updatedActionsSpies . onResult , event : { type : 'result' } } ,
972976 { prop : 'onerror' , option : 'onError' , initial : initialActionsSpies . onError , updated : updatedActionsSpies . onError , event : { type : 'error' } } ,
977+ { prop : 'onend' , option : 'onEnd' , initial : initialActionsSpies . onEnd , updated : updatedActionsSpies . onEnd , event : { type : 'error' } } ,
978+
973979 ] ;
974980
975981 actions . forEach ( ( { prop, option, initial, updated, event } ) => {
@@ -983,14 +989,15 @@ QUnit.module('SpeechRecognitionAdapter integration', moduleConfig, () => {
983989 } ) ;
984990 } ) ;
985991
986- QUnit . test ( 'should allow subscribing to result/error via .on()' , function ( assert ) {
987- assert . expect ( 6 ) ;
992+ QUnit . test ( 'should allow subscribing to result/error/end via .on()' , function ( assert ) {
993+ assert . expect ( 9 ) ;
988994
989995 this . reinit ( ) ;
990996
991997 const events = [
992998 { eventName : 'result' , trigger : 'onresult' } ,
993999 { eventName : 'error' , trigger : 'onerror' } ,
1000+ { eventName : 'end' , trigger : 'onend' } ,
9941001 ] ;
9951002
9961003 const speechRecognition = this . getSpeechRecognition ( ) ;
@@ -1006,6 +1013,20 @@ QUnit.module('SpeechRecognitionAdapter integration', moduleConfig, () => {
10061013 } ) ;
10071014 } ) ;
10081015
1016+ QUnit . test ( 'should stop recognition when disabled set to true at runtime' , function ( assert ) {
1017+ this . reinit ( ) ;
1018+ const adapter = this . getAdapter ( ) ;
1019+ const stopSpy = sinon . spy ( adapter , 'stop' ) ;
1020+
1021+ this . getButton ( ) . trigger ( 'dxclick' ) ;
1022+ assert . ok ( this . $element . hasClass ( SPEECH_TO_TEXT_LISTENING_CLASS ) , 'component in listening state' ) ;
1023+
1024+ this . instance . option ( 'disabled' , true ) ;
1025+
1026+ assert . ok ( stopSpy . calledOnce , 'stop called when disabled' ) ;
1027+ assert . ok ( ! this . $element . hasClass ( SPEECH_TO_TEXT_LISTENING_CLASS ) , 'state reset after disabling' ) ;
1028+ } ) ;
1029+
10091030 QUnit . test ( 'should dispose adapter and set it to null' , function ( assert ) {
10101031 this . reinit ( ) ;
10111032
0 commit comments