Spaces:
Paused
Paused
File size: 638 Bytes
488aedf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | 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");
});
});
|