File tree Expand file tree Collapse file tree 2 files changed +60
-0
lines changed
packages/bundler-plugin-core/src/utils Expand file tree Collapse file tree 2 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { type Options } from "../../types.ts" ;
2
+ import { normalizeOptions , type NormalizedOptions } from "../normalizeOptions" ;
3
+
4
+ interface Test {
5
+ name : string ;
6
+ input : {
7
+ options : Options ;
8
+ } ;
9
+ expected : NormalizedOptions ;
10
+ }
11
+
12
+ const tests : Test [ ] = [
13
+ {
14
+ name : "sets default values" ,
15
+ input : {
16
+ options : { } ,
17
+ } ,
18
+ expected : {
19
+ telemetry : true ,
20
+ apiUrl : "https://api.codecov.io" ,
21
+ dryRun : false ,
22
+ } ,
23
+ } ,
24
+ {
25
+ name : "can override default values" ,
26
+ input : {
27
+ options : {
28
+ apiUrl : "https://api.example.com" ,
29
+ dryRun : true ,
30
+ telemetry : false ,
31
+ } ,
32
+ } ,
33
+ expected : {
34
+ telemetry : false ,
35
+ apiUrl : "https://api.example.com" ,
36
+ dryRun : true ,
37
+ } ,
38
+ } ,
39
+ ] ;
40
+
41
+ describe ( "normalizeOptions" , ( ) => {
42
+ it . each ( tests ) ( "$name" , ( { input, expected } ) => {
43
+ const expectation = normalizeOptions ( input . options ) ;
44
+ expect ( expectation ) . toEqual ( expected ) ;
45
+ } ) ;
46
+ } ) ;
Original file line number Diff line number Diff line change
1
+ import { type Options } from "../types.ts" ;
2
+
3
+ export type NormalizedOptions = ReturnType < typeof normalizeOptions > ;
4
+
5
+ export const normalizeOptions = ( userOptions : Options ) => {
6
+ const options = {
7
+ ...userOptions ,
8
+ telemetry : userOptions . telemetry ?? true ,
9
+ apiUrl : userOptions . apiUrl ?? "https://api.codecov.io" ,
10
+ dryRun : userOptions . dryRun ?? false ,
11
+ } ;
12
+
13
+ return options ;
14
+ } ;
You can’t perform that action at this time.
0 commit comments