Skip to content

Commit 73cd024

Browse files
fixup!: add contrapositive test-case
1 parent dc6b810 commit 73cd024

File tree

1 file changed

+40
-13
lines changed

1 file changed

+40
-13
lines changed

test/rules/line-length.js

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,32 +130,59 @@ https://${'very-'.repeat(80)}-long-url.org/
130130
})
131131

132132
t.test('Co-author lines', (tt) => {
133+
const sha = 'f1496de5a7d5474e39eafaafe6f79befe5883a5b'
134+
const author = {
135+
name: 'Jacob Smith',
136+
137+
date: '2025-12-22T09:40:42Z'
138+
}
139+
133140
const v = new Validator()
134-
const context = new Commit({
135-
sha: 'f1496de5a7d5474e39eafaafe6f79befe5883a5b',
136-
author: {
137-
name: 'Jacob Smith',
138-
139-
date: '2025-12-22T09:40:42Z'
140-
},
141-
message: `
142-
fixup!: apply case-insensitive suggestion
143-
Co-authored-by: Michaël Zasso <[email protected]>
144-
`
141+
const overlongMessage = `
142+
fixup!: apply case-insensitive suggestion
143+
Co-authored-by: Michaël Zasso <[email protected]>
144+
`;
145+
const bad = new Commit({
146+
sha,
147+
author,
148+
message: overlongMessage,
145149
}, v)
146150

147-
context.report = (opts) => {
151+
bad.report = (opts) => {
152+
tt.pass('called report')
153+
tt.equal(opts.id, 'line-length', 'id')
154+
tt.equal(opts.string, overlongMessage.split('\n')[1], 'string')
155+
tt.equal(opts.level, 'fail', 'level')
156+
}
157+
158+
Rule.validate(bad, {
159+
options: {
160+
length: 72
161+
}
162+
})
163+
164+
const good = new Commit({
165+
sha,
166+
author,
167+
message: [
168+
'fixup!: apply case-insensitive suggestion',
169+
'Co-authored-by: Michaël Zasso <[email protected]>'
170+
].join('\n')
171+
}, v)
172+
173+
good.report = (opts) => {
148174
tt.pass('called report')
149175
tt.equal(opts.id, 'line-length', 'id')
150176
tt.equal(opts.string, '', 'string')
151177
tt.equal(opts.level, 'pass', 'level')
152178
}
153179

154-
Rule.validate(context, {
180+
Rule.validate(good, {
155181
options: {
156182
length: 72
157183
}
158184
})
185+
159186
tt.end()
160187
})
161188

0 commit comments

Comments
 (0)