mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
Co-authored-by: claude[bot] <209825114+claude[bot]@users.noreply.github.com> Co-authored-by: Zack Radisic <zackradisic@users.noreply.github.com> Co-authored-by: Jarred Sumner <jarred@jarredsumner.com> Co-authored-by: robobun <robobun@oven.sh>
25 lines
706 B
TypeScript
25 lines
706 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 cd ef\nab cd ef");
|
|
});
|
|
});
|