Files
bun.sh/test/js/bun/shell/commands/yes.test.ts
2024-09-03 21:32:52 -07:00

25 lines
710 B
TypeScript

import { $ } from "bun";
import { describe, expect, test } from "bun:test";
$.throws(false);
describe("yes", async () => {
test("can pipe to a buffer", async () => {
const buffer = Buffer.alloc(10);
await $`yes > ${buffer}`;
expect(buffer.toString()).toEqual("y\ny\ny\ny\ny\n");
});
test("can be overwritten by the first argument", async () => {
const buffer = Buffer.alloc(18);
await $`yes xy > ${buffer}`;
expect(buffer.toString()).toEqual("xy\nxy\nxy\nxy\nxy\nxy\n");
});
test("ignores other arguments", async () => {
const buffer = Buffer.alloc(17);
await $`yes ab cd ef > ${buffer}`;
expect(buffer.toString()).toEqual("ab\nab\nab\nab\nab\nab");
});
});