fixed format issues

This commit is contained in:
Boki 2025-06-26 16:12:27 -04:00
parent a700818a06
commit 08f713d98b
55 changed files with 5680 additions and 5533 deletions

View file

@ -1,21 +1,21 @@
import { describe, it, expect, beforeEach, afterEach } from 'bun:test';
import { afterEach, beforeEach, describe, expect, it } from 'bun:test';
import { z } from 'zod';
import {
SecretValue,
secret,
checkRequiredEnvVars,
COMMON_SECRET_PATTERNS,
createStrictSchema,
formatValidationResult,
isSecret,
redactSecrets,
isSecretEnvVar,
wrapSecretEnvVars,
mergeSchemas,
redactSecrets,
secret,
secretSchema,
secretStringSchema,
COMMON_SECRET_PATTERNS,
validateConfig,
checkRequiredEnvVars,
SecretValue,
validateCompleteness,
formatValidationResult,
createStrictSchema,
mergeSchemas,
validateConfig,
wrapSecretEnvVars,
type ValidationResult,
} from '../src';
@ -100,7 +100,7 @@ describe('Config Utils', () => {
it('should validate SecretValue instances', () => {
const schema = secretSchema(z.string());
const secretVal = new SecretValue('test');
expect(() => schema.parse(secretVal)).not.toThrow();
expect(() => schema.parse('test')).toThrow();
expect(() => schema.parse(null)).toThrow();
@ -132,7 +132,7 @@ describe('Config Utils', () => {
};
const redacted = redactSecrets(obj, ['password', 'nested.apiKey']);
expect(redacted).toEqual({
username: 'admin',
password: '***REDACTED***',
@ -153,7 +153,7 @@ describe('Config Utils', () => {
};
const redacted = redactSecrets(obj);
expect(redacted).toEqual({
normal: 'value',
secret: 'MASKED',
@ -172,7 +172,7 @@ describe('Config Utils', () => {
};
const redacted = redactSecrets(obj);
expect(redacted.items).toEqual([
{ name: 'item1', secret: '***' },
{ name: 'item2', secret: '***' },
@ -187,7 +187,7 @@ describe('Config Utils', () => {
};
const redacted = redactSecrets(obj);
expect(redacted).toEqual({
nullValue: null,
undefinedValue: undefined,
@ -240,13 +240,13 @@ describe('Config Utils', () => {
};
const wrapped = wrapSecretEnvVars(env);
expect(wrapped.USERNAME).toBe('admin');
expect(wrapped.PORT).toBe('3000');
expect(isSecret(wrapped.PASSWORD)).toBe(true);
expect(isSecret(wrapped.API_KEY)).toBe(true);
const passwordSecret = wrapped.PASSWORD as SecretValue;
expect(passwordSecret.reveal('test')).toBe('secret123');
expect(passwordSecret.toString()).toBe('***PASSWORD***');
@ -259,7 +259,7 @@ describe('Config Utils', () => {
};
const wrapped = wrapSecretEnvVars(env);
expect(wrapped.PASSWORD).toBeUndefined();
expect(wrapped.USERNAME).toBe('admin');
});
@ -443,9 +443,7 @@ describe('Config Utils', () => {
it('should format warnings', () => {
const result: ValidationResult = {
valid: true,
warnings: [
{ path: 'deprecated.feature', message: 'This feature is deprecated' },
],
warnings: [{ path: 'deprecated.feature', message: 'This feature is deprecated' }],
};
const formatted = formatValidationResult(result);
@ -499,7 +497,7 @@ describe('Config Utils', () => {
const schema2 = z.object({ b: z.number(), shared: z.string() });
const merged = mergeSchemas(schema1, schema2);
// Both schemas require 'shared' to be a string
expect(() => merged.parse({ a: 'test', b: 123, shared: 'value' })).not.toThrow();
expect(() => merged.parse({ a: 'test', b: 123, shared: 123 })).toThrow();
@ -510,10 +508,10 @@ describe('Config Utils', () => {
it('should be an array of RegExp', () => {
expect(Array.isArray(COMMON_SECRET_PATTERNS)).toBe(true);
expect(COMMON_SECRET_PATTERNS.length).toBeGreaterThan(0);
for (const pattern of COMMON_SECRET_PATTERNS) {
expect(pattern).toBeInstanceOf(RegExp);
}
});
});
});
});