@@ -145,6 +145,46 @@ test('returns minimal summary in case the core.summary is too large for a PR com
145145 expect ( text . length ) . toBeGreaterThan ( minSummary . length )
146146} )
147147
148+ test ( 'returns minimal summary formatted for posting as a PR comment' , ( ) => {
149+ const OLD_ENV = process . env
150+
151+ let changes : Changes = [
152+ createTestChange ( { name : 'lodash' , version : '1.2.3' } ) ,
153+ createTestChange ( { name : 'colors' , version : '2.3.4' } ) ,
154+ createTestChange ( { name : '@foo/bar' , version : '*' } )
155+ ]
156+
157+ process . env . GITHUB_SERVER_URL = 'https://github.com'
158+ process . env . GITHUB_REPOSITORY = 'owner/repo'
159+ process . env . GITHUB_RUN_ID = 'abc-123-xyz'
160+
161+ let minSummary : string = summary . addSummaryToSummary (
162+ changes ,
163+ emptyInvalidLicenseChanges ,
164+ emptyChanges ,
165+ scorecard ,
166+ defaultConfig
167+ )
168+
169+ process . env = OLD_ENV
170+
171+ // note: no Actions context values in unit test env
172+ const expected = `
173+ # Dependency Review
174+ The following issues were found:
175+ * ❌ 3 vulnerable package(s)
176+ * ✅ 0 package(s) with incompatible licenses
177+ * ✅ 0 package(s) with invalid SPDX license definitions
178+ * ✅ 0 package(s) with unknown licenses.
179+
180+ [View full job summary](https://github.com/owner/repo/actions/runs/abc-123-xyz)
181+ ` . trim ( )
182+
183+ expect ( minSummary ) . toEqual ( expected )
184+ } )
185+
186+
187+
148188test ( 'only includes "No vulnerabilities or license issues found"-message if both are configured and nothing was found' , ( ) => {
149189 summary . addSummaryToSummary (
150190 emptyChanges ,
0 commit comments