Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD across contents and paths, upstream package/repo coordinates -> @golem15/msd-core and golem15com/msd-core. Deep links into upstream history, sibling upstream packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is. Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line, package/plugin identity, regenerated lockfile, install-tree fixtures, derived registries and benchmark baseline; migration checksum baseline re-locked (MSD keeps its own install state, so no install had applied the old sums); sort-order and regex-escaped expectations in tests adjusted.
91 lines
2.9 KiB
JavaScript
91 lines
2.9 KiB
JavaScript
// Tests for getMilestoneFromPhaseId and getPhaseDirFromPhaseId helpers (issue #39).
|
|
|
|
'use strict';
|
|
|
|
const { describe, test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const {
|
|
getMilestoneFromPhaseId,
|
|
getPhaseDirFromPhaseId,
|
|
} = require('../msd-core/bin/lib/phase-id.cjs');
|
|
|
|
// ─── getMilestoneFromPhaseId ────────────────────────────────────────────────
|
|
|
|
describe('getMilestoneFromPhaseId', () => {
|
|
test('maps milestone integer 1 to v1.0', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('1-01'), 'v1.0');
|
|
});
|
|
|
|
test('uses only the top-level integer: 2-4-1 → v2.0', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('2-4-1'), 'v2.0');
|
|
});
|
|
|
|
test('handles double-digit milestone: 10-01 → v10.0', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('10-01'), 'v10.0');
|
|
});
|
|
|
|
test('returns null for sentinel 999 (backlog)', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('999-1'), null);
|
|
});
|
|
|
|
test('returns null for sentinel 0 (pre-milestone spike)', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('0-1'), null);
|
|
});
|
|
|
|
test('returns null when there is no hyphen separator', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('1'), null);
|
|
});
|
|
|
|
test('strips project_code prefix: CK-2-01 → v2.0', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('CK-2-01'), 'v2.0');
|
|
});
|
|
|
|
test('strips longer project_code prefix: MSD-10-01 → v10.0', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('MSD-10-01'), 'v10.0');
|
|
});
|
|
|
|
test('returns null for fully non-numeric input', () => {
|
|
assert.strictEqual(getMilestoneFromPhaseId('invalid'), null);
|
|
});
|
|
});
|
|
|
|
// ─── getPhaseDirFromPhaseId ─────────────────────────────────────────────────
|
|
|
|
describe('getPhaseDirFromPhaseId', () => {
|
|
test('produces zero-padded dir with project code', () => {
|
|
assert.strictEqual(
|
|
getPhaseDirFromPhaseId('2-01', 'Setup Database', 'MSD'),
|
|
'MSD-02-01-setup-database',
|
|
);
|
|
});
|
|
|
|
test('omits project code when not provided', () => {
|
|
assert.strictEqual(
|
|
getPhaseDirFromPhaseId('2-01', 'Setup Database'),
|
|
'02-01-setup-database',
|
|
);
|
|
});
|
|
|
|
test('handles double-digit milestone with project code', () => {
|
|
assert.strictEqual(
|
|
getPhaseDirFromPhaseId('10-01', 'Build Feature', 'CK'),
|
|
'CK-10-01-build-feature',
|
|
);
|
|
});
|
|
|
|
test('produces zero-padded dir without project code: 1-01 → 01-01-setup', () => {
|
|
assert.strictEqual(
|
|
getPhaseDirFromPhaseId('1-01', 'Setup'),
|
|
'01-01-setup',
|
|
);
|
|
});
|
|
|
|
test('returns null for phase IDs without the M-NN hyphen form', () => {
|
|
assert.strictEqual(
|
|
getPhaseDirFromPhaseId('nohyphen', 'Some Title', 'MSD'),
|
|
null,
|
|
);
|
|
});
|
|
});
|