@@ -132,6 +132,75 @@ test('it sets the updated dependency as an output for subsequent actions when gi
132132 expect ( core . setOutput ) . toBeCalledWith ( 'cvss' , 0 )
133133} )
134134
135+ test ( 'it sets the updated dependency as an output for subsequent actions when there is a leading v in the commit message version' , async ( ) => {
136+ const mockCommitMessage =
137+ 'Bumps [coffee-rails](https://github.com/rails/coffee-rails) from v4.0.1 to v4.2.2.\n' +
138+ '- [Release notes](https://github.com/rails/coffee-rails/releases)\n' +
139+ '- [Changelog](https://github.com/rails/coffee-rails/blob/master/CHANGELOG.md)\n' +
140+ '- [Commits](rails/[email protected] )\n' + 141+ '\n' +
142+ '---\n' +
143+ 'updated-dependencies:\n' +
144+ '- dependency-name: coffee-rails\n' +
145+ ' dependency-type: direct:production\n' +
146+ '...\n' +
147+ '\n' +
148+ 'Signed-off-by: dependabot[bot] <[email protected] >' 149+ const mockAlert = { alertState : 'FIXED' , ghsaId : 'GSHA' , cvss : 3.4 }
150+
151+ jest . spyOn ( core , 'getInput' ) . mockImplementation ( jest . fn ( ( name ) => { return name === 'github-token' ? 'mock-token' : '' } ) )
152+ jest . spyOn ( util , 'getBranchNames' ) . mockReturnValue ( { headName : 'dependabot|nuget|feature1' , baseName : 'main' } )
153+ jest . spyOn ( dependabotCommits , 'getMessage' ) . mockImplementation ( jest . fn (
154+ ( ) => Promise . resolve ( mockCommitMessage )
155+ ) )
156+ jest . spyOn ( dependabotCommits , 'getAlert' ) . mockImplementation ( jest . fn (
157+ ( ) => Promise . resolve ( mockAlert )
158+ ) )
159+ jest . spyOn ( dependabotCommits , 'getCompatibility' ) . mockImplementation ( jest . fn (
160+ ( ) => Promise . resolve ( 34 )
161+ ) )
162+ jest . spyOn ( core , 'setOutput' ) . mockImplementation ( jest . fn ( ) )
163+
164+ await run ( )
165+
166+ expect ( core . startGroup ) . toHaveBeenCalledWith (
167+ expect . stringContaining ( 'Outputting metadata for 1 updated dependency' )
168+ )
169+
170+ expect ( core . setOutput ) . toHaveBeenCalledWith (
171+ 'updated-dependencies-json' ,
172+ [
173+ {
174+ dependencyName : 'coffee-rails' ,
175+ dependencyType : 'direct:production' ,
176+ updateType : 'version-update:semver-minor' ,
177+ directory : '/' ,
178+ packageEcosystem : 'nuget' ,
179+ targetBranch : 'main' ,
180+ prevVersion : 'v4.0.1' ,
181+ newVersion : 'v4.2.2' ,
182+ compatScore : 0 ,
183+ alertState : '' ,
184+ ghsaId : '' ,
185+ cvss : 0
186+ }
187+ ]
188+ )
189+
190+ expect ( core . setOutput ) . toBeCalledWith ( 'dependency-names' , 'coffee-rails' )
191+ expect ( core . setOutput ) . toBeCalledWith ( 'dependency-type' , 'direct:production' )
192+ expect ( core . setOutput ) . toBeCalledWith ( 'update-type' , 'version-update:semver-minor' )
193+ expect ( core . setOutput ) . toBeCalledWith ( 'directory' , '/' )
194+ expect ( core . setOutput ) . toBeCalledWith ( 'package-ecosystem' , 'nuget' )
195+ expect ( core . setOutput ) . toBeCalledWith ( 'target-branch' , 'main' )
196+ expect ( core . setOutput ) . toBeCalledWith ( 'previous-version' , 'v4.0.1' )
197+ expect ( core . setOutput ) . toBeCalledWith ( 'new-version' , 'v4.2.2' )
198+ expect ( core . setOutput ) . toBeCalledWith ( 'compatibility-score' , 0 )
199+ expect ( core . setOutput ) . toBeCalledWith ( 'alert-state' , '' )
200+ expect ( core . setOutput ) . toBeCalledWith ( 'ghsa-id' , '' )
201+ expect ( core . setOutput ) . toBeCalledWith ( 'cvss' , 0 )
202+ } )
203+
135204test ( 'it sets the updated dependency as an output for subsequent actions when given a commit message for library' , async ( ) => {
136205 const mockCommitMessage =
137206 'Update rubocop requirement from ~> 1.30.1 to ~> 1.31.0\n' +
0 commit comments