Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions bin/commands/__tests__/index.test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';

import { Option } from 'commander';

import commands from '../index.mjs';

describe('Commands', () => {
it('should have unique command names', () => {
const names = new Set();

commands.forEach(({ name }) => {
assert.equal(names.has(name), false, `Duplicate command name: "${name}"`);
names.add(name);
});
});

it('should use correct option names', () => {
commands.forEach(({ name: cmdName, options }) => {
Object.entries(options).forEach(([optName, { flags }]) => {
const expectedName = new Option(flags.at(-1)).attributeName();
assert.equal(
optName,
expectedName,
`In "${cmdName}" command: option "${flags}" should be named "${expectedName}", not "${optName}"`
);
});
});
});
});
Loading