mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { normalizeServerName } from './utils';
|
|
|
|
describe('normalizeServerName', () => {
|
|
it('should not modify server names that already match the pattern', () => {
|
|
const result = normalizeServerName('valid-server_name.123');
|
|
expect(result).toBe('valid-server_name.123');
|
|
});
|
|
|
|
it('should normalize server names with non-ASCII characters', () => {
|
|
const result = normalizeServerName('我的服务');
|
|
// Should generate a fallback name with a hash
|
|
expect(result).toMatch(/^server_\d+$/);
|
|
expect(result).toMatch(/^[a-zA-Z0-9_.-]+$/);
|
|
});
|
|
|
|
it('should normalize server names with special characters', () => {
|
|
const result = normalizeServerName('server@name!');
|
|
// The actual result doesn't have the trailing underscore after trimming
|
|
expect(result).toBe('server_name');
|
|
expect(result).toMatch(/^[a-zA-Z0-9_.-]+$/);
|
|
});
|
|
|
|
it('should trim leading and trailing underscores', () => {
|
|
const result = normalizeServerName('!server-name!');
|
|
expect(result).toBe('server-name');
|
|
expect(result).toMatch(/^[a-zA-Z0-9_.-]+$/);
|
|
});
|
|
});
|