|
1 | 1 | import http from 'node:http' |
2 | 2 | import path from 'node:path' |
3 | 3 | import fs from 'node:fs' |
4 | | -import { afterEach, describe, expect, test } from 'vitest' |
| 4 | +import { afterEach, describe, expect, test, vi } from 'vitest' |
5 | 5 | import type { InlineConfig, PluginOption } from '..' |
6 | 6 | import type { UserConfig, UserConfigExport } from '../config' |
7 | 7 | import { defineConfig, loadConfigFromFile, resolveConfig } from '../config' |
@@ -632,9 +632,22 @@ describe('resolveEnvPrefix', () => {
|
632 | 632 | expect(() => resolveEnvPrefix(config)).toThrow() |
633 | 633 | }) |
634 | 634 | |
| 635 | +test(`show a warning message if envPrefix contains a whitespace`, () => { |
| 636 | +const consoleWarnSpy = vi |
| 637 | +.spyOn(console, 'warn') |
| 638 | +.mockImplementation(() => {}) |
| 639 | +let config: UserConfig = { envPrefix: 'WITH SPACE' } |
| 640 | +resolveEnvPrefix(config) |
| 641 | +expect(consoleWarnSpy).toHaveBeenCalled() |
| 642 | +config = { envPrefix: ['CUSTOM_', 'ANOTHER SPACE'] } |
| 643 | +resolveEnvPrefix(config) |
| 644 | +expect(consoleWarnSpy).toHaveBeenCalledTimes(2) |
| 645 | +consoleWarnSpy.mockRestore() |
| 646 | +}) |
| 647 | + |
635 | 648 | test('should work correctly for valid envPrefix value', () => { |
636 | | -const config: UserConfig = { envPrefix: [' ', 'CUSTOM_'] } |
637 | | -expect(resolveEnvPrefix(config)).toMatchObject([' ', 'CUSTOM_']) |
| 649 | +const config: UserConfig = { envPrefix: ['CUSTOM_'] } |
| 650 | +expect(resolveEnvPrefix(config)).toMatchObject(['CUSTOM_']) |
638 | 651 | }) |
639 | 652 | }) |
640 | 653 | |
|