Skip to content

Commit d03ca6c

Browse files
committed
squash! add tests for multi-line trailers
1 parent 4b1c236 commit d03ca6c

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

test/rules/line-length.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,72 @@ Trailer: value
169169
tt.end()
170170
})
171171

172+
t.test('Multi-line trailers', (tt) => {
173+
const v = new Validator()
174+
175+
const good = new Commit({
176+
sha: 'f1496de5a7d5474e39eafaafe6f79befe5883a5b',
177+
author: {
178+
name: 'Jacob Smith',
179+
180+
date: '2025-12-22T09:40:42Z'
181+
},
182+
message: [
183+
'subsystem: add support for foobar',
184+
'',
185+
'Lorem-Ipsum: dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna',
186+
' aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
187+
' Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint',
188+
' occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
189+
].join('\n')
190+
}, v)
191+
const tooLong = ' Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'
192+
const bad = new Commit({
193+
sha: 'f1496de5a7d5474e39eafaafe6f79befe5883a5b',
194+
author: {
195+
name: 'Jacob Smith',
196+
197+
date: '2025-12-22T09:40:42Z'
198+
},
199+
message: [
200+
'subsystem: add support for foobar',
201+
'',
202+
'Lorem-Ipsum: dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna',
203+
' aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
204+
tooLong
205+
].join('\n')
206+
}, v)
207+
208+
good.report = (opts) => {
209+
tt.pass('called report')
210+
tt.equal(opts.id, 'line-length', 'id')
211+
tt.equal(opts.string, '', 'string')
212+
tt.equal(opts.level, 'pass', 'level')
213+
}
214+
bad.report = (opts) => {
215+
tt.pass('called report')
216+
tt.equal(opts.id, 'line-length', 'id')
217+
tt.equal(opts.message, 'Trailer should be <= 120 columns.', 'message')
218+
tt.equal(opts.string, tooLong, 'string')
219+
tt.equal(opts.level, 'fail', 'level')
220+
}
221+
222+
Rule.validate(good, {
223+
options: {
224+
length: 72,
225+
trailerLength: 120
226+
}
227+
})
228+
Rule.validate(bad, {
229+
options: {
230+
length: 72,
231+
trailerLength: 120
232+
}
233+
})
234+
235+
tt.end()
236+
})
237+
172238
t.test('Signed-off-by and Assisted-by trailers', (tt) => {
173239
const v = new Validator()
174240

0 commit comments

Comments
 (0)