mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-01 03:45:53 -05:00
Co-authored-by: Anthony <anthony@infraly.co> Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
30 lines
972 B
TypeScript
30 lines
972 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import type { AdminAllocation } from '@/api/admin/nodes/queries';
|
|
import { allocationLabel } from './helpers';
|
|
|
|
const allocation = (alias: string | null): AdminAllocation => ({
|
|
object: 'allocation',
|
|
attributes: {
|
|
id: 1,
|
|
ip: '10.0.0.1',
|
|
alias,
|
|
port: 25565,
|
|
notes: null,
|
|
server_id: null,
|
|
server_name: null,
|
|
assigned: false,
|
|
},
|
|
});
|
|
|
|
describe('allocationLabel', () => {
|
|
it('prefers an alias that differs from the IP', () => {
|
|
expect(allocationLabel(allocation('play.example.com'))).toBe('play.example.com:25565');
|
|
});
|
|
|
|
it('falls back to the IP for a missing, empty, or redundant alias', () => {
|
|
expect(allocationLabel(allocation(null))).toBe('10.0.0.1:25565');
|
|
expect(allocationLabel(allocation(''))).toBe('10.0.0.1:25565');
|
|
expect(allocationLabel(allocation('10.0.0.1'))).toBe('10.0.0.1:25565');
|
|
});
|
|
});
|