@@ -32,4 +32,54 @@ describe("Screen.", () => {
32
32
await sleep ( 1000 ) ;
33
33
expect ( existsSync ( filename ) ) . toBeTruthy ( ) ;
34
34
} ) ;
35
+
36
+ it ( "should capture the screen and save file with prefix" , async ( ) => {
37
+ // GIVEN
38
+ const visionAdapter = new VisionAdapter ( ) ;
39
+ const SUT = new Screen ( visionAdapter ) ;
40
+ const prefix = "foo_" ;
41
+
42
+ // WHEN
43
+ const filename = await SUT . capture ( "asdf.txt" , FileType . JPG , "./" , prefix ) ;
44
+
45
+ // THEN
46
+ expect ( filename . includes ( prefix ) ) . toBeTruthy ( ) ;
47
+ expect ( filename ) . not . toBeNull ( ) ;
48
+ await sleep ( 1000 ) ;
49
+ expect ( existsSync ( filename ) ) . toBeTruthy ( ) ;
50
+ } ) ;
51
+
52
+ it ( "should capture the screen and save file with postfix" , async ( ) => {
53
+ // GIVEN
54
+ const visionAdapter = new VisionAdapter ( ) ;
55
+ const SUT = new Screen ( visionAdapter ) ;
56
+ const postfix = "_bar" ;
57
+
58
+ // WHEN
59
+ const filename = await SUT . capture ( "asdf.txt" , FileType . JPG , "./" , "" , postfix ) ;
60
+
61
+ // THEN
62
+ expect ( filename . includes ( postfix ) ) . toBeTruthy ( ) ;
63
+ expect ( filename ) . not . toBeNull ( ) ;
64
+ await sleep ( 1000 ) ;
65
+ expect ( existsSync ( filename ) ) . toBeTruthy ( ) ;
66
+ } ) ;
67
+
68
+ it ( "should capture the screen and save file with pre- and postfix" , async ( ) => {
69
+ // GIVEN
70
+ const visionAdapter = new VisionAdapter ( ) ;
71
+ const SUT = new Screen ( visionAdapter ) ;
72
+ const filename = "asdf" ;
73
+ const prefix = "foo_" ;
74
+ const postfix = "_bar" ;
75
+
76
+ // WHEN
77
+ const output = await SUT . capture ( "asdf" , FileType . JPG , "./" , prefix , postfix ) ;
78
+
79
+ // THEN
80
+ expect ( output . includes ( `${ prefix } ${ filename } ${ postfix } ` ) ) . toBeTruthy ( ) ;
81
+ expect ( output ) . not . toBeNull ( ) ;
82
+ await sleep ( 1000 ) ;
83
+ expect ( existsSync ( output ) ) . toBeTruthy ( ) ;
84
+ } ) ;
35
85
} ) ;
0 commit comments