File tree Expand file tree Collapse file tree 3 files changed +75
-3
lines changed Expand file tree Collapse file tree 3 files changed +75
-3
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
+ } ) ;
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ coverage:
9
9
target : 80%
10
10
project :
11
11
default :
12
- # TODO(@avivkeller): Once our coverage > 50 %,
13
- # increase this to 50 %, and increase on increments
14
- target : 40 %
12
+ # TODO(@avivkeller): Once our coverage > 70 %,
13
+ # increase this to 70 %, and increase on increments
14
+ target : 60 %
15
15
16
16
ignore :
17
17
- ' eslint.config.mjs'
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 semver from 'semver' ;
5
+
6
+ import { allGenerators } from '../index.mjs' ;
7
+
8
+ const validDependencies = [ ...Object . keys ( allGenerators ) , 'ast' ] ;
9
+ const generatorEntries = Object . entries ( allGenerators ) ;
10
+
11
+ describe ( 'All Generators' , ( ) => {
12
+ it ( 'should have keys matching their name property' , ( ) => {
13
+ generatorEntries . forEach ( ( [ key , generator ] ) => {
14
+ assert . equal (
15
+ key ,
16
+ generator . name ,
17
+ `Generator key "${ key } " does not match its name property "${ generator . name } "`
18
+ ) ;
19
+ } ) ;
20
+ } ) ;
21
+
22
+ it ( 'should have valid semver versions' , ( ) => {
23
+ generatorEntries . forEach ( ( [ key , generator ] ) => {
24
+ const isValid = semver . valid ( generator . version ) ;
25
+ assert . ok (
26
+ isValid ,
27
+ `Generator "${ key } " has invalid semver version: "${ generator . version } "`
28
+ ) ;
29
+ } ) ;
30
+ } ) ;
31
+
32
+ it ( 'should have valid dependsOn references' , ( ) => {
33
+ generatorEntries . forEach ( ( [ key , generator ] ) => {
34
+ if ( generator . dependsOn ) {
35
+ assert . ok (
36
+ validDependencies . includes ( generator . dependsOn ) ,
37
+ `Generator "${ key } " depends on "${ generator . dependsOn } " which is not a valid generator or 'ast'`
38
+ ) ;
39
+ }
40
+ } ) ;
41
+ } ) ;
42
+ } ) ;
You can’t perform that action at this time.
0 commit comments