mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 00:57:45 +00:00
21 lines
771 B
TypeScript
21 lines
771 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { normalizeMachineName } from './machine-name'
|
|
|
|
describe('normalizeMachineName', () => {
|
|
it('trims surrounding whitespace', () => {
|
|
expect(normalizeMachineName(' Build server \n')).toBe('Build server')
|
|
})
|
|
|
|
it('caps the stored length after trimming', () => {
|
|
expect(normalizeMachineName(` ${'x'.repeat(255)} `)).toBe('x'.repeat(255))
|
|
expect(normalizeMachineName(` ${'x'.repeat(256)} `)).toBe('x'.repeat(255))
|
|
})
|
|
|
|
it('reads anything that is not a string as the detected-name default', () => {
|
|
expect(normalizeMachineName(undefined)).toBe('')
|
|
expect(normalizeMachineName(null)).toBe('')
|
|
expect(normalizeMachineName(42)).toBe('')
|
|
expect(normalizeMachineName(' ')).toBe('')
|
|
})
|
|
})
|