@@ -12,7 +12,8 @@ describe('<GuiControls />', () => {
1212 AcceptOpenedButton = sandbox . stub ( ) . returns ( null ) ;
1313 actionsStub = {
1414 runAllTests : sandbox . stub ( ) . returns ( { type : 'some-type' } ) ,
15- runFailedTests : sandbox . stub ( ) . returns ( { type : 'some-type' } )
15+ runFailedTests : sandbox . stub ( ) . returns ( { type : 'some-type' } ) ,
16+ stopTests : sandbox . stub ( ) . returns ( { type : 'some-type' } )
1617 } ;
1718 selectors = {
1819 getFailedTests : sandbox . stub ( ) . returns ( [ ] )
@@ -116,4 +117,44 @@ describe('<GuiControls />', () => {
116117 assert . calledOnce ( AcceptOpenedButton ) ;
117118 } ) ;
118119 } ) ;
120+
121+ describe ( '"Stop tests" button' , ( ) => {
122+ it ( 'should be disabled when tests are not running' , ( ) => {
123+ const component = mkConnectedComponent ( < GuiControls /> , {
124+ initialState : { running : false , stopping : false }
125+ } ) ;
126+
127+ const stop = component . find ( '[label="Stop tests"]' ) ;
128+ assert . isTrue ( stop . prop ( 'isDisabled' ) ) ;
129+ } ) ;
130+
131+ describe ( 'should be disabled when tests are' , ( ) => {
132+ it ( 'running' , ( ) => {
133+ const component = mkConnectedComponent ( < GuiControls /> , {
134+ initialState : { running : true , stopping : false }
135+ } ) ;
136+
137+ const stop = component . find ( '[label="Stop tests"]' ) ;
138+ assert . isFalse ( stop . prop ( 'isDisabled' ) ) ;
139+ } ) ;
140+
141+ it ( 'stopping' , ( ) => {
142+ const component = mkConnectedComponent ( < GuiControls /> , {
143+ initialState : { running : true , stopping : true }
144+ } ) ;
145+
146+ const stop = component . find ( '[label="Stop tests"]' ) ;
147+ assert . isTrue ( stop . prop ( 'isDisabled' ) ) ;
148+ } ) ;
149+ } ) ;
150+
151+ it ( 'should call "stopTests" action on click' , ( ) => {
152+ const component = mkConnectedComponent ( < GuiControls /> , {
153+ initialState : { running : true }
154+ } ) ;
155+
156+ component . find ( '[label="Stop tests"]' ) . simulate ( 'click' ) ;
157+ assert . calledOnce ( actionsStub . stopTests ) ;
158+ } ) ;
159+ } ) ;
119160} ) ;
0 commit comments