Skip to content

Commit d202cc6

Browse files
authored
file-entry-cache - feat: adding in test example for eslint (#1396)
1 parent 034388f commit d202cc6

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/file-entry-cache/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
},
3939
"devDependencies": {
4040
"@biomejs/biome": "^2.2.5",
41-
"@types/node": "^24.7.0",
41+
"@types/node": "^24.7.1",
4242
"@vitest/coverage-v8": "^3.2.4",
4343
"pino": "^10.0.0",
4444
"rimraf": "^6.0.1",

packages/file-entry-cache/test/relative-eslint.test.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from "node:fs";
22
import path from "node:path";
33
import { describe, expect, test } from "vitest";
44
import fileEntryCache, {
5+
type CreateOptions,
56
FileEntryCache,
67
type FileEntryCacheOptions,
78
} from "../src/index.js";
@@ -109,4 +110,33 @@ describe("eslint tests scenarios", () => {
109110
expect(fileDescriptor2.changed).toBe(false);
110111
expect(fileDescriptor2.meta.hash).toBeDefined();
111112
});
113+
114+
test("create with cwd and use absolute path key", () => {
115+
const cacheDirectory = "./.cache";
116+
const cacheId = ".eslintcache-202121212";
117+
const file = "../src/index.ts";
118+
const useCheckSum = true;
119+
const useAbsolutePathAsKey = true;
120+
const cwd = cacheDirectory;
121+
122+
const options: CreateOptions = {
123+
useCheckSum,
124+
useAbsolutePathAsKey,
125+
cwd,
126+
};
127+
128+
const cache = fileEntryCache.create(cacheId, cacheDirectory, options);
129+
130+
const fileDescriptor = cache.getFileDescriptor(file);
131+
132+
expect(fileDescriptor.changed).toBe(true);
133+
expect(fileDescriptor.meta.hash).toBeDefined();
134+
135+
cache.reconcile();
136+
137+
const fileDescriptor2 = cache.getFileDescriptor(file);
138+
139+
expect(fileDescriptor2.changed).toBe(false);
140+
expect(fileDescriptor2.meta.hash).toBeDefined();
141+
});
112142
});

0 commit comments

Comments
 (0)