@@ -35,6 +35,7 @@ describe('lib/small-timer-runner', () => {
3535 onMsgType : 'str' ,
3636 wrapMidnight : false ,
3737 debugEnable : false ,
38+ minimumOnTime : 0 ,
3839 id : '' ,
3940 type : '' ,
4041 name : '' ,
@@ -46,7 +47,7 @@ describe('lib/small-timer-runner', () => {
4647 getTimeToNextStartEvent : sinon . stub ( ) ,
4748 getTimeToNextEndEvent : sinon . stub ( ) ,
4849 getOnState : sinon . stub ( ) . returns ( false ) ,
49- noOnStateToday : sinon . stub ( ) . returns ( false ) ,
50+ operationToday : sinon . stub ( ) . returns ( 'normal' ) ,
5051 debug : sinon . stub ( ) . returns ( { debug : 'this is debug' } ) ,
5152 }
5253
@@ -74,15 +75,33 @@ describe('lib/small-timer-runner', () => {
7475 const stubs = setupTest ( )
7576 stubs . stubbedTimeCalc . getTimeToNextStartEvent . returns ( 10 )
7677 stubs . stubbedTimeCalc . getTimeToNextEndEvent . returns ( 20 )
77- stubs . stubbedTimeCalc . noOnStateToday . returns ( true )
78+ stubs . stubbedTimeCalc . operationToday . returns ( 'noMidnightWrap' )
7879
79- new SmallTimerRunner ( stubs . position , stubs . configuration , stubs . node )
80+ const runner = new SmallTimerRunner ( stubs . position , stubs . configuration , stubs . node )
8081
82+ runner . onMessage ( { payload : 'sync' , _msgid : '' } )
8183 sinon . assert . calledWith ( stubs . node . status , {
8284 fill : 'yellow' ,
8385 shape : 'dot' ,
8486 text : 'No action today - off time is before on time' ,
8587 } )
88+
89+ } )
90+
91+ it ( 'should handle no action today, due to minimum on time not met' , ( ) => {
92+ const stubs = setupTest ( )
93+ stubs . stubbedTimeCalc . getTimeToNextStartEvent . returns ( 10 )
94+ stubs . stubbedTimeCalc . getTimeToNextEndEvent . returns ( 20 )
95+ stubs . stubbedTimeCalc . operationToday . returns ( 'minimumOnTimeNotMet' )
96+
97+ const runner = new SmallTimerRunner ( stubs . position , stubs . configuration , stubs . node )
98+
99+ runner . onMessage ( { payload : 'sync' , _msgid : '' } )
100+ sinon . assert . calledWith ( stubs . node . status , {
101+ fill : 'yellow' ,
102+ shape : 'dot' ,
103+ text : 'No action today - minimum on time not met' ,
104+ } )
86105 } )
87106
88107 it ( 'should handle temporary on and use timeout to calculate next change' , ( ) => {
@@ -138,7 +157,9 @@ describe('lib/small-timer-runner', () => {
138157 stubs . stubbedTimeCalc . getTimeToNextEndEvent . returns ( 120.6 )
139158 stubs . stubbedTimeCalc . getOnState . returns ( false )
140159
141- new SmallTimerRunner ( stubs . position , stubs . configuration , stubs . node )
160+ const runner = new SmallTimerRunner ( stubs . position , stubs . configuration , stubs . node )
161+
162+ runner . onMessage ( { payload : 'sync' , _msgid : '' } )
142163 sinon . clock . tick ( 60000 )
143164
144165 sinon . assert . calledWithExactly ( stubs . status , { fill : 'red' , shape : 'dot' , text : 'OFF for 00mins 00secs' } )
@@ -184,8 +205,9 @@ describe('lib/small-timer-runner', () => {
184205 stubs . stubbedTimeCalc . getTimeToNextEndEvent . returns ( 120.6 )
185206 stubs . stubbedTimeCalc . getOnState . returns ( false )
186207
187- new SmallTimerRunner ( stubs . position , stubs . configuration , stubs . node )
208+ const runner = new SmallTimerRunner ( stubs . position , stubs . configuration , stubs . node )
188209
210+ runner . onMessage ( { payload : 'sync' , _msgid : '' } )
189211 sinon . clock . tick ( 2000 )
190212 sinon . assert . calledWith ( stubs . send , [
191213 {
@@ -200,8 +222,8 @@ describe('lib/small-timer-runner', () => {
200222 } ,
201223 { debug : 'this is debug' , override : 'auto' , topic : 'debug' } ,
202224 ] )
203-
204225 } )
226+
205227 it ( 'should stop timer, and not advance anything after cleanup has been called' , async ( ) => {
206228 const stubs = setupTest ( {
207229 topic : 'test-topic' ,
@@ -297,8 +319,6 @@ describe('lib/small-timer-runner', () => {
297319 payload : '0' ,
298320 topic : 'test-topic' ,
299321 } )
300-
301-
302322 } )
303323
304324 it ( 'should output node status when sync message is received, without changing properties' , ( ) => {
0 commit comments