|
1 | 1 | import test from 'node:test' |
2 | 2 | import assert from 'node:assert/strict' |
3 | | -import { computeDeathIndex } from './scoring' |
| 3 | +import { computeDeathIndex, generateLastWords } from './scoring' |
4 | 4 | import type { RepoData } from './types' |
5 | 5 |
|
6 | 6 | function buildRepo(overrides: Partial<RepoData> = {}): RepoData { |
@@ -34,3 +34,50 @@ test('inactive repo with many issues gets high death index', () => { |
34 | 34 | const score = computeDeathIndex(repo) |
35 | 35 | assert.ok(score >= 5) |
36 | 36 | }) |
| 37 | + |
| 38 | +// ── generateLastWords ────────────────────────────────────────────── |
| 39 | + |
| 40 | +test('"initial commit" returns beginning quote', () => { |
| 41 | + const repo = buildRepo({ lastCommitMessage: 'initial commit', lastCommitDate: new Date().toISOString() }) |
| 42 | + assert.equal(generateLastWords(repo), 'it was only ever the beginning') |
| 43 | +}) |
| 44 | + |
| 45 | +test('"revert" returns nevermind', () => { |
| 46 | + const repo = buildRepo({ lastCommitMessage: 'revert: undo migration', lastCommitDate: new Date().toISOString() }) |
| 47 | + assert.equal(generateLastWords(repo), 'nevermind') |
| 48 | +}) |
| 49 | + |
| 50 | +test('"hotfix" returns this is fine', () => { |
| 51 | + const repo = buildRepo({ lastCommitMessage: 'hotfix: patch auth flow', lastCommitDate: new Date().toISOString() }) |
| 52 | + assert.equal(generateLastWords(repo), 'this is fine') |
| 53 | +}) |
| 54 | + |
| 55 | +test('"cleanup" returns tidying quote', () => { |
| 56 | + const repo = buildRepo({ lastCommitMessage: 'cleanup unused imports', lastCommitDate: new Date().toISOString() }) |
| 57 | + assert.equal(generateLastWords(repo), 'just tidying up before i go') |
| 58 | +}) |
| 59 | + |
| 60 | +test('"bump version" returns release quote', () => { |
| 61 | + const repo = buildRepo({ lastCommitMessage: 'bump version to 3.0.0', lastCommitDate: new Date().toISOString() }) |
| 62 | + assert.equal(generateLastWords(repo), 'one last release into the void') |
| 63 | +}) |
| 64 | + |
| 65 | +test('"remove" returns burning the evidence', () => { |
| 66 | + const repo = buildRepo({ lastCommitMessage: 'remove deprecated API', lastCommitDate: new Date().toISOString() }) |
| 67 | + assert.equal(generateLastWords(repo), 'burning the evidence') |
| 68 | +}) |
| 69 | + |
| 70 | +test('"refactor" returns architecture quote', () => { |
| 71 | + const repo = buildRepo({ lastCommitMessage: 'refactor auth module', lastCommitDate: new Date().toISOString() }) |
| 72 | + assert.equal(generateLastWords(repo), 'i swear this time the architecture is right') |
| 73 | +}) |
| 74 | + |
| 75 | +test('"todo" returns someone else quote', () => { |
| 76 | + const repo = buildRepo({ lastCommitMessage: 'add todo for error handling', lastCommitDate: new Date().toISOString() }) |
| 77 | + assert.equal(generateLastWords(repo), 'someone else will handle it') |
| 78 | +}) |
| 79 | + |
| 80 | +test('"dependencies" returns dependency hell', () => { |
| 81 | + const repo = buildRepo({ lastCommitMessage: 'update dependencies', lastCommitDate: new Date().toISOString() }) |
| 82 | + assert.equal(generateLastWords(repo), 'trapped in dependency hell') |
| 83 | +}) |
0 commit comments