@@ -2,6 +2,7 @@ import { describe, expect, vi } from 'vitest';
22import { autoloadRc , readRcByPath } from '@code-pushup/core' ;
33import {
44 coreConfigMiddleware ,
5+ normalizeBooleanWithNegation ,
56 normalizeFormats ,
67} from './core-config.middleware.js' ;
78import type { CoreConfigCliOptions } from './core-config.model.js' ;
@@ -19,6 +20,36 @@ vi.mock('@code-pushup/core', async () => {
1920 } ;
2021} ) ;
2122
23+ describe ( 'normalizeBooleanWithNegation' , ( ) => {
24+ it ( 'should return true when CLI property is true' , ( ) => {
25+ expect ( normalizeBooleanWithNegation ( 'report' , { report : true } , { } ) ) . toBe (
26+ true ,
27+ ) ;
28+ } ) ;
29+
30+ it ( 'should return false when CLI property is false' , ( ) => {
31+ expect ( normalizeBooleanWithNegation ( 'report' , { report : false } , { } ) ) . toBe (
32+ false ,
33+ ) ;
34+ } ) ;
35+
36+ it ( 'should return false when no-property exists in CLI persist' , ( ) => {
37+ expect (
38+ normalizeBooleanWithNegation ( 'report' , { 'no-report' : true } , { } ) ,
39+ ) . toBe ( false ) ;
40+ } ) ;
41+
42+ it ( 'should fallback to RC persist when no CLI property' , ( ) => {
43+ expect ( normalizeBooleanWithNegation ( 'report' , { } , { report : false } ) ) . toBe (
44+ false ,
45+ ) ;
46+ } ) ;
47+
48+ it ( 'should return default true when no property anywhere' , ( ) => {
49+ expect ( normalizeBooleanWithNegation ( 'report' , { } , { } ) ) . toBe ( true ) ;
50+ } ) ;
51+ } ) ;
52+
2253describe ( 'normalizeFormats' , ( ) => {
2354 it ( 'should forward valid formats' , ( ) => {
2455 expect ( normalizeFormats ( [ 'json' , 'md' ] ) ) . toEqual ( [ 'json' , 'md' ] ) ;
0 commit comments