Skip to content

Commit 5c31084

Browse files
committed
Cover MIA guard branches
1 parent f579024 commit 5c31084

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

tests/dri.test.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { describe, it, expect } from 'vitest';
22

3-
import { extractDri, formatDri, formatAssignee } from '../docs/dri.js';
3+
import { extractDri, formatDri, formatAssignee, resolveCoderHandle } from '../docs/dri.js';
44

55
const baseOpts = { driToken: 'DRI:@', coderBodyFlag: 'coder', coderLabelFlag: 'op_mia' };
66

@@ -45,3 +45,19 @@ describe('format helpers', () => {
4545
expect(text).toContain('pls code');
4646
});
4747
});
48+
49+
describe('resolveCoderHandle', () => {
50+
it('returns DRI handle when author is MIA', () => {
51+
const item = { user: { login: 'bob' }, labels: [{ name: 'DRI:@alice' }, { name: 'op_mia' }] };
52+
const dri = extractDri(item, baseOpts);
53+
const handle = resolveCoderHandle(item, dri, baseOpts);
54+
expect(handle).toBe('@alice');
55+
});
56+
57+
it('returns not found when author is MIA but DRI is missing', () => {
58+
const item = { user: { login: 'bob' }, labels: [{ name: 'op_mia' }] };
59+
const dri = extractDri(item, baseOpts);
60+
const handle = resolveCoderHandle(item, dri, baseOpts);
61+
expect(handle).toBe('not found');
62+
});
63+
});

tests/dri_body.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ describe('extractDri body vs label', () => {
2525
expect(dri.role).toBe('review');
2626
});
2727

28+
it('treats missing body as not MIA when DRI is in labels', () => {
29+
const item = { user: { login: 'bob' }, labels: [{ name: 'DRI:@alice' }] };
30+
const dri = extractDri(item, baseOpts);
31+
expect(dri.handle).toBe('@alice');
32+
expect(dri.role).toBe('review');
33+
});
34+
35+
it('ignores empty DRI handle when checking MIA body flag', () => {
36+
const item = { user: { login: 'bob' }, body: 'DRI:@@ coder', labels: [] };
37+
const dri = extractDri(item, baseOpts);
38+
expect(dri.handle).toBe('@');
39+
expect(dri.role).toBe('review');
40+
});
41+
2842
it('marks coder via body flag even if not author', () => {
2943
const item = { user: { login: 'charlie' }, body: 'DRI:@alice coder', labels: [] };
3044
const dri = extractDri(item, baseOpts);

0 commit comments

Comments
 (0)