@agnishc/edb-append-system-prompt 0.10.8 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/utils.test.ts +48 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { formatAge, wordCount } from "./utils.js";
|
|
3
|
+
|
|
4
|
+
describe("formatAge", () => {
|
|
5
|
+
it("formats seconds", () => {
|
|
6
|
+
const now = Date.now();
|
|
7
|
+
expect(formatAge(now - 0)).toBe("0s ago");
|
|
8
|
+
expect(formatAge(now - 30 * 1000)).toBe("30s ago");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("formats minutes", () => {
|
|
12
|
+
const now = Date.now();
|
|
13
|
+
expect(formatAge(now - 60 * 1000)).toBe("1m ago");
|
|
14
|
+
expect(formatAge(now - 5 * 60 * 1000)).toBe("5m ago");
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it("formats hours", () => {
|
|
18
|
+
const now = Date.now();
|
|
19
|
+
expect(formatAge(now - 3600 * 1000)).toBe("1h ago");
|
|
20
|
+
expect(formatAge(now - 12 * 3600 * 1000)).toBe("12h ago");
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("formats days", () => {
|
|
24
|
+
const now = Date.now();
|
|
25
|
+
expect(formatAge(now - 86400 * 1000)).toBe("1d ago");
|
|
26
|
+
expect(formatAge(now - 7 * 86400 * 1000)).toBe("7d ago");
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("wordCount", () => {
|
|
31
|
+
it("counts words", () => {
|
|
32
|
+
expect(wordCount("hello world")).toBe(2);
|
|
33
|
+
expect(wordCount("one two three")).toBe(3);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("ignores extra whitespace", () => {
|
|
37
|
+
expect(wordCount(" hello world ")).toBe(2);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it("returns 0 for empty string", () => {
|
|
41
|
+
expect(wordCount("")).toBe(0);
|
|
42
|
+
expect(wordCount(" ")).toBe(0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("handles newline-separated words", () => {
|
|
46
|
+
expect(wordCount("hello\nworld")).toBe(2);
|
|
47
|
+
});
|
|
48
|
+
});
|