Skip to content

Commit 37af3a8

Browse files
fixup!: add contrapositive test-case
1 parent dc6b810 commit 37af3a8

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

test/rules/line-length.js

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,32 +130,58 @@ 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+
email: '3012099+JakobJingleheimer@users.noreply.github.com',
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-
email: '3012099+JakobJingleheimer@users.noreply.github.com',
139-
date: '2025-12-22T09:40:42Z'
140-
},
141+
const bad = new Commit({
142+
sha,
143+
author,
141144
message: `
142145
fixup!: apply case-insensitive suggestion
143146
Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>
144147
`
145148
}, v)
146149

147-
context.report = (opts) => {
150+
bad.report = (opts) => {
148151
tt.pass('called report')
149152
tt.equal(opts.id, 'line-length', 'id')
150153
tt.equal(opts.string, '', 'string')
151154
tt.equal(opts.level, 'pass', 'level')
152155
}
153156

154-
Rule.validate(context, {
157+
Rule.validate(bad, {
158+
options: {
159+
length: 72
160+
}
161+
})
162+
163+
const good = new Commit({
164+
sha,
165+
author,
166+
message: [
167+
'fixup!: apply case-insensitive suggestion',
168+
'Co-authored-by: Michaël Zasso <37011812+targos@users.noreply.github.com>'
169+
].join('\n')
170+
}, v)
171+
172+
good.report = (opts) => {
173+
tt.pass('called report')
174+
tt.equal(opts.id, 'line-length', 'id')
175+
tt.equal(opts.string, '', 'string')
176+
tt.equal(opts.level, 'pass', 'level')
177+
}
178+
179+
Rule.validate(good, {
155180
options: {
156181
length: 72
157182
}
158183
})
184+
159185
tt.end()
160186
})
161187

0 commit comments

Comments
 (0)