This repository was archived by the owner on May 4, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { ACTION_ANALYZE } from "../utils/constants" ;
2+ import { executeCommand } from "./test-utils" ;
3+
4+ describe ( "codiga analyze" , ( ) => {
5+ test ( "should catch an invalid directory" , async ( ) => {
6+ // run the command
7+ await executeCommand ( [ ACTION_ANALYZE , "invalid-directory" ] ) . catch (
8+ ( { stderr } ) => {
9+ expect ( stderr ) . toMatch ( / N o s u c h f i l e o r d i r e c t o r y t o a n a l y z e / ) ;
10+ }
11+ ) ;
12+ } ) ;
13+
14+ test ( "should catch when a file is specified without rulesets" , async ( ) => {
15+ // run the command
16+ await executeCommand ( [ ACTION_ANALYZE , "tests/test-utils.js" ] ) . catch (
17+ ( { stderr } ) => {
18+ expect ( stderr ) . toMatch ( / N o r u l e s e t s w e r e g i v e n t o a n a l y z e t h i s f i l e / ) ;
19+ }
20+ ) ;
21+ } ) ;
22+
23+ test ( "1 invalid ruleset; 0 valid ruleset; should catch error" , async ( ) => {
24+ // run the command
25+ await executeCommand ( [
26+ ACTION_ANALYZE ,
27+ "tests/test-utils.js" ,
28+ "--ruleset invalid-ruleset" ,
29+ ] ) . catch ( ( { stderr } ) => {
30+ expect ( stderr ) . toMatch ( / N o v a l i d r u l e s e t s w e r e f o u n d t o c o n t i n u e / ) ;
31+ } ) ;
32+ } ) ;
33+
34+ test ( "1 invalid ruleset; 1 valid ruleset; should have invalid notice" , async ( ) => {
35+ // run the command
36+ await executeCommand ( [
37+ ACTION_ANALYZE ,
38+ "tests/test-utils.js" ,
39+ "--ruleset invalid-ruleset" ,
40+ "--ruleset testing-ruleset-1" ,
41+ ] ) . catch ( ( { stdout } ) => {
42+ expect ( stdout ) . toMatch (
43+ / T h e f o l l o w i n g r u l e s e t s e i t h e r d o n ' t e x i s t o r y o u l a c k t h e p e r m i s s i o n s t o a c c e s s i t /
44+ ) ;
45+ expect ( stdout ) . toMatch ( / - i n v a l i d - r u l e s e t / ) ;
46+ } ) ;
47+ } ) ;
48+ } ) ;
You can’t perform that action at this time.
0 commit comments