forked from JoshuaKGoldberg/TypeStat
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcollectFileNames.test.ts
More file actions
31 lines (26 loc) · 1.21 KB
/
collectFileNames.test.ts
File metadata and controls
31 lines (26 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { describe, expect, it } from "vitest";
import { collectFileNames } from "./collectFileNames.js";
describe("collectFileNames", () => {
it("should collect files with wildcard when collection succeeds", async () => {
const cwd = process.cwd();
const res = await collectFileNames(cwd, ["src/*"]);
expect(res?.fileNames).toContain(`${cwd}/src/collectFileNames.test.ts`);
});
it("should return undefined if includes is empty array", async () => {
const cwd = process.cwd();
const res = await collectFileNames(cwd, []);
expect(res).toBeUndefined();
});
it("should return error if node_modules are implicitly included", async () => {
const cwd = process.cwd();
const res = await collectFileNames(cwd, ["*"]);
expect(res?.error).toEqual(
`At least one path including node_modules was included implicitly: '${cwd}/node_modules'. Either adjust TypeStat's included files to not include node_modules (recommended) or explicitly include node_modules/ (not recommended).`,
);
});
it("should NOT return error if node_modules are explicitly included", async () => {
const cwd = process.cwd();
const res = await collectFileNames(cwd, ["node_modules"]);
expect(res?.fileNames.length).toBeGreaterThan(0);
});
});