File tree 1 file changed +39
-0
lines changed
1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { Heart } from "../../../src/node/heart"
2
+ import { clean , mockLogger , tmpdir } from "../../utils/helpers"
3
+
4
+ describe ( "Heart" , ( ) => {
5
+ function isFakeActive ( resolveTo : boolean ) : ( ) => Promise < boolean > {
6
+ return ( ) => new Promise ( ( resolve ) => setTimeout ( ( ) => resolve ( resolveTo ) , 500 ) )
7
+ }
8
+ const testName = "heartTests"
9
+ let testDir = ""
10
+
11
+ beforeAll ( async ( ) => {
12
+ mockLogger ( )
13
+ await clean ( testName )
14
+ testDir = await tmpdir ( testName )
15
+ } )
16
+
17
+ it . todo ( "should write to a file when given a valid file path" )
18
+ // create a file in testDir with contents
19
+ // call beat
20
+ // check that files contents have changed
21
+ it . todo ( "should log a warning when given an invalid file path" )
22
+ // instantiate with empty file
23
+ // call beat
24
+ // expect warning to be called
25
+
26
+ it . todo ( "should let you know if the beat is alive" )
27
+ // instantiate
28
+ // call beat
29
+ // check if alive
30
+
31
+ it ( "should shutdown when dispose is called" , ( ) => {
32
+ const isActiveTrue = isFakeActive ( true )
33
+ const heart = new Heart ( `${ testDir } /shutdown.txt` , isActiveTrue )
34
+ heart . dispose ( )
35
+
36
+ const isAlive = heart . alive ( )
37
+ expect ( isAlive ) . toBe ( false )
38
+ } )
39
+ } )
You can’t perform that action at this time.
0 commit comments