@@ -37,6 +37,22 @@ describe("Logger", () => {
3737 } ) ;
3838 } ) ;
3939
40+ describe ( "kept" , ( ) => {
41+ it ( "does not log when debug is false" , ( ) => {
42+ const logger = new Logger ( false ) ;
43+ logger . kept ( "main.js" , "scripts" ) ;
44+
45+ expect ( consoleSpy ) . not . toHaveBeenCalled ( ) ;
46+ } ) ;
47+
48+ it ( "logs with label when debug is true" , ( ) => {
49+ const logger = new Logger ( true ) ;
50+ logger . kept ( "main.js" , "scripts" ) ;
51+
52+ expect ( consoleSpy ) . toHaveBeenCalledWith ( "[FilterChunk] Kept: main.js (label: scripts)" ) ;
53+ } ) ;
54+ } ) ;
55+
4056 describe ( "summary" , ( ) => {
4157 it ( "does not log summary when debug is false and no webpack logger" , ( ) => {
4258 const logger = new Logger ( false ) ;
@@ -68,6 +84,46 @@ describe("Logger", () => {
6884 expect ( consoleSpy ) . toHaveBeenCalledWith ( " licenses:" ) ;
6985 expect ( consoleSpy ) . toHaveBeenCalledWith ( " - c.LICENSE.txt" ) ;
7086 } ) ;
87+
88+ it ( "logs include mode summary when debug is true" , ( ) => {
89+ const logger = new Logger ( true ) ;
90+ logger . kept ( "main.js" , "scripts" ) ;
91+ logger . kept ( "vendor.js" , "scripts" ) ;
92+ logger . summary ( 5 , 3 , true ) ;
93+
94+ expect ( consoleSpy ) . toHaveBeenCalledWith ( "[FilterChunk] Kept 2 of 5 assets (3 removed)" ) ;
95+ } ) ;
96+
97+ it ( "logs grouped kept files by label in include mode" , ( ) => {
98+ const logger = new Logger ( true ) ;
99+ logger . kept ( "main.js" , "scripts" ) ;
100+ logger . kept ( "vendor.js" , "scripts" ) ;
101+ logger . kept ( "style.css" , "styles" ) ;
102+ logger . summary ( 5 , 2 , true ) ;
103+
104+ expect ( consoleSpy ) . toHaveBeenCalledWith ( "[FilterChunk] Kept assets:" ) ;
105+ expect ( consoleSpy ) . toHaveBeenCalledWith ( " scripts:" ) ;
106+ expect ( consoleSpy ) . toHaveBeenCalledWith ( " - main.js" ) ;
107+ expect ( consoleSpy ) . toHaveBeenCalledWith ( " - vendor.js" ) ;
108+ expect ( consoleSpy ) . toHaveBeenCalledWith ( " styles:" ) ;
109+ expect ( consoleSpy ) . toHaveBeenCalledWith ( " - style.css" ) ;
110+ } ) ;
111+
112+ it ( "does not log filtered assets list when none filtered in exclude mode" , ( ) => {
113+ const logger = new Logger ( true ) ;
114+ logger . summary ( 5 , 0 ) ;
115+
116+ expect ( consoleSpy ) . toHaveBeenCalledWith ( "[FilterChunk] Filtered 0 of 5 assets (5 remaining)" ) ;
117+ expect ( consoleSpy ) . not . toHaveBeenCalledWith ( "[FilterChunk] Filtered assets:" ) ;
118+ } ) ;
119+
120+ it ( "does not log kept assets list when none kept in include mode" , ( ) => {
121+ const logger = new Logger ( true ) ;
122+ logger . summary ( 5 , 5 , true ) ;
123+
124+ expect ( consoleSpy ) . toHaveBeenCalledWith ( "[FilterChunk] Kept 0 of 5 assets (5 removed)" ) ;
125+ expect ( consoleSpy ) . not . toHaveBeenCalledWith ( "[FilterChunk] Kept assets:" ) ;
126+ } ) ;
71127 } ) ;
72128
73129 describe ( "webpack logger integration" , ( ) => {
0 commit comments