zcode-daili / src /async /keepalive.test.ts
bolikoto's picture
chore(zcode): 升级上游至 v4.8.5 并保留多账号兼容
488aedf verified
Raw History Blame Contribute Delete
638 Bytes
import { describe, it, expect } from "bun:test";
import { keepaliveFrame } from "./keepalive.js";
describe("keepaliveFrame", () => {
it("produces a single frame with default text", () => {
const frame = keepaliveFrame();
expect(new TextDecoder().decode(frame)).toBe(": keepalive\n\n");
});
it("produces a frame with custom text", () => {
const frame = keepaliveFrame("hello");
expect(new TextDecoder().decode(frame)).toBe(": hello\n\n");
});
it("strips newlines from custom text", () => {
const frame = keepaliveFrame("a\nb\rc");
expect(new TextDecoder().decode(frame)).toBe(": a b c\n\n");
});
});