2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-11-30 23:46:45 +01:00
|
|
|
const {strict: assert} = require("assert");
|
|
|
|
|
2023-02-22 23:04:10 +01:00
|
|
|
const {zrequire} = require("./lib/namespace");
|
|
|
|
const {run_test} = require("./lib/test");
|
2020-12-01 00:02:16 +01:00
|
|
|
|
2019-06-20 11:59:55 +02:00
|
|
|
const blueslip_stacktrace = zrequire("blueslip_stacktrace");
|
|
|
|
|
|
|
|
run_test("clean_path", () => {
|
|
|
|
// Local file
|
|
|
|
assert.strictEqual(
|
2024-05-15 04:24:25 +02:00
|
|
|
blueslip_stacktrace.clean_path("webpack:///web/src/upload.ts"),
|
|
|
|
"/web/src/upload.ts",
|
2019-06-20 11:59:55 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Third party library (jQuery)
|
|
|
|
assert.strictEqual(
|
|
|
|
blueslip_stacktrace.clean_path(
|
2020-07-02 02:16:03 +02:00
|
|
|
"webpack:///.-npm-cache/de76fb6f582a29b053274f9048b6158091351048/node_modules/jquery/dist/jquery.js",
|
2019-06-20 11:59:55 +02:00
|
|
|
),
|
2020-07-02 02:16:03 +02:00
|
|
|
"jquery/dist/jquery.js",
|
2019-06-20 11:59:55 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Third party library (underscore)
|
|
|
|
assert.strictEqual(
|
|
|
|
blueslip_stacktrace.clean_path(
|
2020-07-02 02:16:03 +02:00
|
|
|
"webpack:///.-npm-cache/de76fb6f582a29b053274f9048b…58091351048/node_modules/underscore/underscore.js",
|
2019-06-20 11:59:55 +02:00
|
|
|
),
|
2020-07-02 02:16:03 +02:00
|
|
|
"underscore/underscore.js",
|
2019-06-20 11:59:55 +02:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
run_test("clean_function_name", () => {
|
|
|
|
assert.deepEqual(blueslip_stacktrace.clean_function_name(undefined), undefined);
|
|
|
|
|
|
|
|
// Local file
|
|
|
|
assert.deepEqual(
|
2024-05-15 04:24:25 +02:00
|
|
|
blueslip_stacktrace.clean_function_name("Object../web/src/upload.ts.exports.options"),
|
2019-06-20 11:59:55 +02:00
|
|
|
{
|
2024-05-15 04:24:25 +02:00
|
|
|
scope: "Object../web/src/upload.ts.exports.",
|
2019-06-20 11:59:55 +02:00
|
|
|
name: "options",
|
2020-07-02 02:16:03 +02:00
|
|
|
},
|
2019-06-20 11:59:55 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
// Third party library (jQuery)
|
|
|
|
assert.deepEqual(blueslip_stacktrace.clean_function_name("mightThrow"), {
|
|
|
|
scope: "",
|
|
|
|
name: "mightThrow",
|
|
|
|
});
|
|
|
|
|
|
|
|
// Third party library (underscore)
|
|
|
|
assert.deepEqual(
|
|
|
|
blueslip_stacktrace.clean_function_name(
|
2020-07-02 02:16:03 +02:00
|
|
|
"Function.../zulip-npm-cache/de76fb6f582a29b053274f…es/underscore/underscore.js?3817._.each._.forEach",
|
2019-06-20 11:59:55 +02:00
|
|
|
),
|
|
|
|
{
|
2021-05-09 22:29:53 +02:00
|
|
|
scope: "Function.../zulip-npm-cache/de76fb6f582a29b053274f…es/underscore/underscore.js?3817._.each._.",
|
2019-06-20 11:59:55 +02:00
|
|
|
name: "forEach",
|
2020-07-02 02:16:03 +02:00
|
|
|
},
|
2019-06-20 11:59:55 +02:00
|
|
|
);
|
|
|
|
});
|