@@ -4,109 +4,135 @@ import {
44 docCoveragePluginConfigSchema ,
55} from './config.js' ;
66
7- describe ( 'docCoveragePluginConfigSchema' , ( ) => {
8- it ( 'accepts a valid configuration' , ( ) => {
9- expect ( ( ) =>
10- docCoveragePluginConfigSchema . parse ( {
11- sourceGlob : [ 'src/**/*.ts' ] ,
12- onlyAudits : [ 'functions-coverage' ] ,
13- } satisfies DocCoveragePluginConfig ) ,
14- ) . not . toThrow ( ) ;
15- } ) ;
7+ describe ( 'DocCoveragePlugin Configuration' , ( ) => {
8+ describe ( 'docCoveragePluginConfigSchema' , ( ) => {
9+ it ( 'accepts a valid configuration' , ( ) => {
10+ expect ( ( ) =>
11+ docCoveragePluginConfigSchema . parse ( {
12+ sourceGlob : [ 'src/**/*.ts' ] ,
13+ onlyAudits : [ 'functions-coverage' ] ,
14+ } satisfies DocCoveragePluginConfig ) ,
15+ ) . not . toThrow ( ) ;
16+ } ) ;
1617
17- it ( 'throws when skipAudits and onlyAudits are defined' , ( ) => {
18- expect ( ( ) =>
19- docCoveragePluginConfigSchema . parse ( {
20- skipAudits : [ 'functions-coverage' ] ,
21- onlyAudits : [ 'classes-coverage' ] ,
22- } ) ,
23- ) . toThrow ( "You can't define 'skipAudits' and 'onlyAudits' simultaneously" ) ;
18+ it ( 'throws when skipAudits and onlyAudits are defined' , ( ) => {
19+ expect ( ( ) =>
20+ docCoveragePluginConfigSchema . parse ( {
21+ skipAudits : [ 'functions-coverage' ] ,
22+ onlyAudits : [ 'classes-coverage' ] ,
23+ } ) ,
24+ ) . toThrow (
25+ "You can't define 'skipAudits' and 'onlyAudits' simultaneously" ,
26+ ) ;
27+ } ) ;
2428 } ) ;
25- } ) ;
2629
27- describe ( 'sourceGlob' , ( ) => {
28- it ( 'accepts a valid source glob pattern' , ( ) => {
29- expect ( ( ) =>
30- docCoveragePluginConfigSchema . parse ( {
31- sourceGlob : [ 'src/**/*.{ts,tsx}' , '!**/*.spec.ts' , '!**/*.test.ts' ] ,
32- } satisfies DocCoveragePluginConfig ) ,
33- ) . not . toThrow ( ) ;
34- } ) ;
30+ describe ( 'sourceGlob' , ( ) => {
31+ it ( 'accepts a valid source glob pattern' , ( ) => {
32+ expect ( ( ) =>
33+ docCoveragePluginConfigSchema . parse ( {
34+ sourceGlob : [ 'src/**/*.{ts,tsx}' , '!**/*.spec.ts' , '!**/*.test.ts' ] ,
35+ } satisfies DocCoveragePluginConfig ) ,
36+ ) . not . toThrow ( ) ;
37+ } ) ;
3538
36- it ( 'uses default value for missing sourceGlob' , ( ) => {
37- const result = docCoveragePluginConfigSchema . parse ( { } ) ;
38- expect ( result . sourceGlob ) . toEqual ( [
39- 'src/**/*.{ts,tsx}' ,
40- '!**/*.spec.ts' ,
41- '!**/*.test.ts' ,
42- ] ) ;
43- } ) ;
39+ it ( 'uses default value for missing sourceGlob' , ( ) => {
40+ const result = docCoveragePluginConfigSchema . parse ( { } ) ;
41+ expect ( result . sourceGlob ) . toEqual ( [
42+ 'src/**/*.{ts,tsx}' ,
43+ '!**/*.spec.ts' ,
44+ '!**/*.test.ts' ,
45+ ] ) ;
46+ } ) ;
4447
45- it ( 'throws for invalid sourceGlob type' , ( ) => {
46- expect ( ( ) =>
47- docCoveragePluginConfigSchema . parse ( {
48- sourceGlob : 123 ,
49- } ) ,
50- ) . toThrow ( 'Expected array' ) ;
48+ it ( 'throws for invalid sourceGlob type' , ( ) => {
49+ expect ( ( ) =>
50+ docCoveragePluginConfigSchema . parse ( {
51+ sourceGlob : 123 ,
52+ } ) ,
53+ ) . toThrow ( 'Expected array' ) ;
54+ } ) ;
5155 } ) ;
52- } ) ;
5356
54- describe ( 'onlyAudits' , ( ) => {
55- it ( 'accepts a valid `onlyAudits` array' , ( ) => {
56- expect ( ( ) =>
57- docCoveragePluginConfigSchema . parse ( {
58- onlyAudits : [ 'functions-coverage' , 'classes-coverage' ] ,
59- sourceGlob : [ 'src/**/*.ts' ] ,
60- } ) ,
61- ) . not . toThrow ( ) ;
62- } ) ;
57+ describe ( 'onlyAudits' , ( ) => {
58+ it ( 'accepts a valid `onlyAudits` array' , ( ) => {
59+ expect ( ( ) =>
60+ docCoveragePluginConfigSchema . parse ( {
61+ onlyAudits : [ 'functions-coverage' , 'classes-coverage' ] ,
62+ sourceGlob : [ 'src/**/*.ts' ] ,
63+ } ) ,
64+ ) . not . toThrow ( ) ;
65+ } ) ;
6366
64- it ( 'accepts empty array for onlyAudits' , ( ) => {
65- expect ( ( ) =>
66- docCoveragePluginConfigSchema . parse ( {
67- onlyAudits : [ ] ,
68- sourceGlob : [ 'src/**/*.ts' ] ,
69- } ) ,
70- ) . not . toThrow ( ) ;
71- } ) ;
67+ it ( 'accepts empty array for onlyAudits' , ( ) => {
68+ expect ( ( ) =>
69+ docCoveragePluginConfigSchema . parse ( {
70+ onlyAudits : [ ] ,
71+ sourceGlob : [ 'src/**/*.ts' ] ,
72+ } ) ,
73+ ) . not . toThrow ( ) ;
74+ } ) ;
7275
73- it ( 'allows onlyAudits to be undefined' , ( ) => {
74- const result = docCoveragePluginConfigSchema . parse ( { } ) ;
75- expect ( result . onlyAudits ) . toBeUndefined ( ) ;
76- } ) ;
76+ it ( 'allows onlyAudits to be undefined' , ( ) => {
77+ const result = docCoveragePluginConfigSchema . parse ( { } ) ;
78+ expect ( result . onlyAudits ) . toBeUndefined ( ) ;
79+ } ) ;
7780
78- it ( 'throws for invalid onlyAudits type' , ( ) => {
79- expect ( ( ) =>
80- docCoveragePluginConfigSchema . parse ( {
81- onlyAudits : 'functions-coverage' ,
82- } ) ,
83- ) . toThrow ( 'Expected array' ) ;
84- } ) ;
81+ it ( 'throws for invalid onlyAudits type' , ( ) => {
82+ expect ( ( ) =>
83+ docCoveragePluginConfigSchema . parse ( {
84+ onlyAudits : 'functions-coverage' ,
85+ } ) ,
86+ ) . toThrow ( 'Expected array' ) ;
87+ } ) ;
8588
86- it ( 'throws for array with non-string elements' , ( ) => {
87- expect ( ( ) =>
88- docCoveragePluginConfigSchema . parse ( {
89- onlyAudits : [ 123 , true ] ,
90- } ) ,
91- ) . toThrow ( 'Expected string' ) ;
89+ it ( 'throws for array with non-string elements' , ( ) => {
90+ expect ( ( ) =>
91+ docCoveragePluginConfigSchema . parse ( {
92+ onlyAudits : [ 123 , true ] ,
93+ } ) ,
94+ ) . toThrow ( 'Expected string' ) ;
95+ } ) ;
9296 } ) ;
93- } ) ;
9497
95- describe ( 'skipAudits' , ( ) => {
96- it ( 'accepts valid audit slugs array' , ( ) => {
97- expect ( ( ) =>
98- docCoveragePluginConfigSchema . parse ( {
99- skipAudits : [ 'functions-coverage' , 'classes-coverage' ] ,
100- sourceGlob : [ 'src/**/*.ts' ] ,
101- } ) ,
102- ) . not . toThrow ( ) ;
103- } ) ;
98+ describe ( 'skipAudits' , ( ) => {
99+ it ( 'accepts valid audit slugs array' , ( ) => {
100+ expect ( ( ) =>
101+ docCoveragePluginConfigSchema . parse ( {
102+ skipAudits : [ 'functions-coverage' , 'classes-coverage' ] ,
103+ sourceGlob : [ 'src/**/*.ts' ] ,
104+ } ) ,
105+ ) . not . toThrow ( ) ;
106+ } ) ;
107+
108+ it ( 'accepts empty array for skipAudits' , ( ) => {
109+ expect ( ( ) =>
110+ docCoveragePluginConfigSchema . parse ( {
111+ skipAudits : [ ] ,
112+ sourceGlob : [ 'src/**/*.ts' ] ,
113+ } ) ,
114+ ) . not . toThrow ( ) ;
115+ } ) ;
116+
117+ it ( 'allows skipAudits to be undefined' , ( ) => {
118+ const result = docCoveragePluginConfigSchema . parse ( { } ) ;
119+ expect ( result . skipAudits ) . toBeUndefined ( ) ;
120+ } ) ;
121+
122+ it ( 'throws for invalid skipAudits type' , ( ) => {
123+ expect ( ( ) =>
124+ docCoveragePluginConfigSchema . parse ( {
125+ skipAudits : 'functions-coverage' ,
126+ } ) ,
127+ ) . toThrow ( 'Expected array' ) ;
128+ } ) ;
104129
105- it ( 'throws for array with non-string elements' , ( ) => {
106- expect ( ( ) =>
107- docCoveragePluginConfigSchema . parse ( {
108- skipAudits : [ 123 , true ] ,
109- } ) ,
110- ) . toThrow ( 'Expected string' ) ;
130+ it ( 'throws for array with non-string elements' , ( ) => {
131+ expect ( ( ) =>
132+ docCoveragePluginConfigSchema . parse ( {
133+ skipAudits : [ 123 , true ] ,
134+ } ) ,
135+ ) . toThrow ( 'Expected string' ) ;
136+ } ) ;
111137 } ) ;
112138} ) ;
0 commit comments