Files
agentic-dev/packages/core-eslint/rules/_workspace.test.js
Danijel Martinek f77e6ea881 chore(template): clean-slate template snapshot from bb4a0c7
Curated, product-agnostic snapshot of the post-story-04 tree: demo
content deleted, auth-only reference feature, web-next shell, all gates
green. Product-specific docs, ADRs 027-029, PRDs/epics/archive, editor
library traces, and product naming are curated out; generic template
repairs (coverage provider devDeps, root test:coverage script, live
lint fixes, root-only release-please) are kept. See TEMPLATE.md for
provenance, curation list, and usage.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016j8z4VHjedXDTjEDNg7qHK
2026-07-12 20:40:54 +02:00

35 lines
1.0 KiB
JavaScript

import { describe, it, expect } from "vitest";
import path from "node:path";
import os from "node:os";
import fs from "node:fs";
import { readWorkspacePackages } from "./_workspace.js";
function writeWorkspaceYaml(contents) {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "workspace-"));
const filepath = path.join(dir, "pnpm-workspace.yaml");
fs.writeFileSync(filepath, contents);
return { dir, filepath };
}
describe("_workspace", () => {
it("returns the list of declared package globs", () => {
const { dir } = writeWorkspaceYaml(
`packages:
- "apps/*"
- "packages/*"
`,
);
expect(readWorkspacePackages(dir)).toEqual(["apps/*", "packages/*"]);
});
it("returns [] when pnpm-workspace.yaml is missing", () => {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "workspace-"));
expect(readWorkspacePackages(dir)).toEqual([]);
});
it("returns [] when packages key is absent", () => {
const { dir } = writeWorkspaceYaml(`# empty\n`);
expect(readWorkspacePackages(dir)).toEqual([]);
});
});