|
1 | | -import { describe, it, expect, vi, beforeEach } from 'vitest'; |
| 1 | +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; |
2 | 2 | import { PluginsLoader } from '../../../../lib/compiler/plugins/plugins-loader.js'; |
3 | 3 | import { SwcCompiler } from '../../../../lib/compiler/swc/swc-compiler.js'; |
4 | 4 |
|
@@ -307,4 +307,37 @@ describe('SWC Compiler', () => { |
307 | 307 | expect(closeWatchersMock).toHaveBeenCalledTimes(2); |
308 | 308 | }); |
309 | 309 | }); |
| 310 | + |
| 311 | + describe('shouldLogSwcStatus', () => { |
| 312 | + const originalLogLevel = process.env.npm_config_loglevel; |
| 313 | + |
| 314 | + afterEach(() => { |
| 315 | + process.env.npm_config_loglevel = originalLogLevel; |
| 316 | + }); |
| 317 | + |
| 318 | + it('should return false when extras.silent is true', () => { |
| 319 | + const result = compiler['shouldLogSwcStatus']({ |
| 320 | + silent: true, |
| 321 | + } as any); |
| 322 | + expect(result).toBe(false); |
| 323 | + }); |
| 324 | + |
| 325 | + it('should return false when npm log level is silent', () => { |
| 326 | + process.env.npm_config_loglevel = 'silent'; |
| 327 | + |
| 328 | + const result = compiler['shouldLogSwcStatus']({ |
| 329 | + silent: false, |
| 330 | + } as any); |
| 331 | + expect(result).toBe(false); |
| 332 | + }); |
| 333 | + |
| 334 | + it('should return true when silent mode is not enabled', () => { |
| 335 | + process.env.npm_config_loglevel = 'warn'; |
| 336 | + |
| 337 | + const result = compiler['shouldLogSwcStatus']({ |
| 338 | + silent: false, |
| 339 | + } as any); |
| 340 | + expect(result).toBe(true); |
| 341 | + }); |
| 342 | + }); |
310 | 343 | }); |
0 commit comments