Elffuss BraidHub

kikocis/continue public

main · 3.4 KiBRawPermalink
1// Generated by continue
2
3import { extractMinimalStackTraceInfo } from "./extractMinimalStackTraceInfo";
4
5describe("extractMinimalStackTraceInfo", () => {
6 it("should return an empty string when stack is not a string or an empty string", () => {
7 expect(extractMinimalStackTraceInfo(undefined)).toBe("");
8 expect(extractMinimalStackTraceInfo(null)).toBe("");
9 expect(extractMinimalStackTraceInfo(1234)).toBe("");
10 expect(extractMinimalStackTraceInfo({})).toBe("");
11 expect(extractMinimalStackTraceInfo([])).toBe("");
12 expect(extractMinimalStackTraceInfo(true)).toBe("");
13 expect(extractMinimalStackTraceInfo("")).toBe("");
14 });
15
16 it("should extract minimal stack trace info from a valid stack trace", () => {
17 const stack = `Error: Something went wrong
18 at FunctionOne (/Users/user/project/file1.ts:10:15)
19 at FunctionTwo (/Users/user/project/file2.ts:20:25)
20 at FunctionThree (/Users/user/project/file3.ts:30:35)
21 at node_modules/some_module/index.js:40:45
22 at FunctionFour (/Users/user/project/file4.ts:50:55)
23 at processTicksAndRejections (node:internal/process/task_queues:96:5)
24 `;
25 const expected = "FunctionOne, FunctionTwo, FunctionThree, FunctionFour";
26 expect(extractMinimalStackTraceInfo(stack)).toBe(expected);
27 });
28
29 it("should return an empty string if no matching lines are found", () => {
30 const stack = `Error: Something went wrong
31 at node_modules/some_module/index.js:40:45
32 at processTicksAndRejections (node:internal/process/task_queues:96:5)
33 `;
34 expect(extractMinimalStackTraceInfo(stack)).toBe("");
35 });
36
37 it("should handle stack traces without 'at ' at the beginning of lines", () => {
38 const stack = `Error: Something went wrong
39 in FunctionOne (/Users/user/project/file1.ts:10:15)
40 in FunctionTwo (/Users/user/project/file2.ts:20:25)
41 `;
42 expect(extractMinimalStackTraceInfo(stack)).toBe("");
43 });
44
45 it("should handle stack traces with varying whitespace", () => {
46 const stack = `Error: Something went wrong
47at FunctionOne (/Users/user/project/file1.ts:10:15)
48 at FunctionTwo(/Users/user/project/file2.ts:20:25)
49 at FunctionThree (/Users/user/project/file3.ts:30:35)
50 `;
51 const expected = "FunctionOne, FunctionTwo(), FunctionThree";
52 expect(extractMinimalStackTraceInfo(stack)).toBe(expected);
53 });
54
55 it("should correctly handle function names with spaces and special characters", () => {
56 const stack = `Error: Something went wrong
57 at Object.Function One (/Users/user/project/file1.ts:10:15)
58 at Module.<anonymous> (/Users/user/project/file2.ts:20:25)
59 at Function_Two (/Users/user/project/file3.ts:30:35)
60 `;
61 const expected = "Object.Function One, Module.<anonymous>, Function_Two";
62 expect(extractMinimalStackTraceInfo(stack)).toBe(expected);
63 });
64
65 it("should handle stack traces with anonymous functions", () => {
66 const stack = `Error: Something went wrong
67 at /Users/user/project/file1.ts:10:15
68 at /Users/user/project/file2.ts:20:25
69 at node_modules/some_module/index.js:40:45
70 `;
71 expect(extractMinimalStackTraceInfo(stack)).toBe("");
72 });
73
74 it("should handle lines without parentheses", () => {
75 const stack = `Error: Something went wrong
76 at FunctionOne
77 at FunctionTwo
78 at FunctionThree (/Users/user/project/file3.ts:30:35)
79 `;
80 const expected = "FunctionOne, FunctionTwo, FunctionThree";
81 expect(extractMinimalStackTraceInfo(stack)).toBe(expected);
82 });
83});