File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 1+ import assert from 'node:assert/strict' ;
2+ import { describe , it } from 'node:test' ;
3+
4+ import { Option } from 'commander' ;
5+
6+ import commands from '../index.mjs' ;
7+
8+ describe ( 'Commands' , ( ) => {
9+ it ( 'should have unique command names' , ( ) => {
10+ const names = new Set ( ) ;
11+
12+ commands . forEach ( ( { name } ) => {
13+ assert . equal ( names . has ( name ) , false , `Duplicate command name: "${ name } "` ) ;
14+ names . add ( name ) ;
15+ } ) ;
16+ } ) ;
17+
18+ it ( 'should use correct option names' , ( ) => {
19+ commands . forEach ( ( { name : cmdName , options } ) => {
20+ Object . entries ( options ) . forEach ( ( [ optName , { flags } ] ) => {
21+ const expectedName = new Option ( flags . at ( - 1 ) ) . attributeName ( ) ;
22+ assert . equal (
23+ optName ,
24+ expectedName ,
25+ `In "${ cmdName } " command: option "${ flags } " should be named "${ expectedName } ", not "${ optName } "`
26+ ) ;
27+ } ) ;
28+ } ) ;
29+ } ) ;
30+ } ) ;
You can’t perform that action at this time.
0 commit comments