@@ -42,4 +42,33 @@ describe('Changelog', () => {
42
42
expect ( fs . existsSync ( settings . changelogFilePath ) ) . toBe ( true )
43
43
expect ( fileContent ) . toEqual ( expectedFileContent )
44
44
} )
45
+
46
+ it ( 'Verifies changelog is saved to default file' , async ( ) => {
47
+ const settings = { } as Settings
48
+ settings . changelogFilePath = 'CHANGELOG.md'
49
+
50
+ const gitLog : GitCommit [ ] = [
51
+ new GitCommit ( '295b513' , 'Third commit' ) ,
52
+ new GitCommit ( '0dad212' , 'Second commit' ) ,
53
+ new GitCommit ( '80913ba' , 'First commit' )
54
+ ]
55
+ const changelog = new Changelog ( settings )
56
+ changelog . write ( gitLog )
57
+
58
+ // Read created CHANGELOG.md
59
+ const fileContent : string = fs . readFileSync ( settings . changelogFilePath ) . toString ( )
60
+
61
+ const expectedFileContent : string = [
62
+ '# Changelog' ,
63
+ '295b513 Third commit' ,
64
+ '0dad212 Second commit' ,
65
+ '80913ba First commit'
66
+ ] . join ( '\n' )
67
+
68
+ // Verifies file is created and contains expected data
69
+ expect ( fs . existsSync ( settings . changelogFilePath ) ) . toBe ( true )
70
+ expect ( fileContent ) . toEqual ( expectedFileContent )
71
+
72
+ io . rmRF ( settings . changelogFilePath )
73
+ } )
45
74
} )
0 commit comments