9 lines
1.2 KiB
TypeScript
9 lines
1.2 KiB
TypeScript
import { test } from "node:test"
|
|
import assert from "node:assert/strict"
|
|
import { readProbeOutput } from "./probe-response"
|
|
test("Диагностика требует подтверждённый string output",()=>{for(const raw of [null,{},[],{output:null},{output:1},{output:"ok",error:"fail"}])assert.throws(()=>readProbeOutput(raw));assert.equal(readProbeOutput({output:""}),"");assert.equal(readProbeOutput({output:"PING"}),"PING")})
|
|
test("Диагностика отклоняет legacy error и oversized output",()=>{assert.throws(()=>readProbeOutput({output:" error: отказ"}),/отказ/);assert.throws(()=>readProbeOutput({output:"x".repeat(1024*1024+1)}))})
|
|
|
|
import { probeServersSchema } from "./probe-response"
|
|
test("Каталог диагностики требует уникальные id и достоверный status/enabled",()=>{const row={id:1,name:"Тест",host:"192.0.2.1",type:"exit-node",enabled:true,status:null};assert.equal(probeServersSchema.safeParse([row]).success,true);for(const rows of [[row,row],[{...row,id:0}],[{...row,status:"active"}],[{...row,enabled:"yes"}]])assert.equal(probeServersSchema.safeParse(rows).success,false)})
|