mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-18 18:04:45 +00:00
test: guard extension helper null checks
This commit is contained in:
@@ -107,8 +107,9 @@ function getActPostHandler() {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(value, label).toBeTypeOf("object");
|
||||
expect(value, label).not.toBeNull();
|
||||
if (!value || typeof value !== "object") {
|
||||
throw new Error(`expected ${label}`);
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,8 +35,6 @@ async function expectSetupErrorStatus(
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${label} was not an object`);
|
||||
}
|
||||
|
||||
@@ -69,8 +69,9 @@ function expectInputText(text: string) {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(value, label).toBeTypeOf("object");
|
||||
expect(value, label).not.toBeNull();
|
||||
if (!value || typeof value !== "object") {
|
||||
throw new Error(`expected ${label}`);
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ function createContractTool(overrides: Partial<AnyAgentTool>): AnyAgentTool {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${label} was not an object`);
|
||||
}
|
||||
|
||||
@@ -50,8 +50,9 @@ function compileManifestConfigSchema() {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(value, label).toBeTypeOf("object");
|
||||
expect(value, label).not.toBeNull();
|
||||
if (!value || typeof value !== "object") {
|
||||
throw new Error(`expected ${label}`);
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1282,7 +1282,6 @@ describe("handleFeishuMessage command authorization", () => {
|
||||
expect(finalized.OriginatingTo).toBe("chat:oc-group");
|
||||
expect(finalized.SenderId).toBe("ou-allowed");
|
||||
const groupSessionKey = resolveGroupSessionKey(finalized as never);
|
||||
expect(groupSessionKey).not.toBeNull();
|
||||
if (!groupSessionKey) {
|
||||
throw new Error("Expected group session key");
|
||||
}
|
||||
|
||||
@@ -64,8 +64,9 @@ type ToolResultWithDetails = {
|
||||
const WORKSPACE_ROOT = path.resolve("/workspace");
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(value, label).toBeTypeOf("object");
|
||||
expect(value, label).not.toBeNull();
|
||||
if (!value || typeof value !== "object") {
|
||||
throw new Error(`expected ${label}`);
|
||||
}
|
||||
return value as Record<string, unknown>;
|
||||
}
|
||||
|
||||
|
||||
@@ -108,8 +108,6 @@ function createCtx(overrides: {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${label} was not an object`);
|
||||
}
|
||||
|
||||
@@ -51,8 +51,6 @@ function withConfig(fileTransfer: Record<string, unknown> | undefined) {
|
||||
}
|
||||
|
||||
function expectResultFields(result: unknown, fields: Record<string, unknown>) {
|
||||
expect(typeof result).toBe("object");
|
||||
expect(result).not.toBeNull();
|
||||
if (typeof result !== "object" || result === null) {
|
||||
throw new Error("policy result was not an object");
|
||||
}
|
||||
|
||||
@@ -47,8 +47,6 @@ class MockMatrixClient {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${label} was not an object`);
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@ function expectBodiesExclude(bodies: string[], text: string) {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${label} was not an object`);
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ function requestUrl(input: RequestInfo | URL | undefined): string {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${label} was not an object`);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ function installQaChannelTestRegistry() {
|
||||
}
|
||||
|
||||
function expectDispatchedContext(ctx: Record<string, unknown> | null): Record<string, unknown> {
|
||||
expect(ctx).not.toBeNull();
|
||||
if (ctx === null) {
|
||||
throw new Error("Expected dispatched context");
|
||||
}
|
||||
|
||||
@@ -49,8 +49,6 @@ describe("handleSlackAction", () => {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${label} was not an object`);
|
||||
}
|
||||
|
||||
@@ -220,10 +220,12 @@ describe("VoiceCallWebhookServer realtime transcription provider selection", ()
|
||||
expect(mocks.getRealtimeTranscriptionProvider).not.toHaveBeenCalled();
|
||||
expect(mocks.listRealtimeTranscriptionProviders).toHaveBeenCalledWith(null);
|
||||
const mediaStreamHandler = server.getMediaStreamHandler();
|
||||
expect(mediaStreamHandler).not.toBeNull();
|
||||
expect(mediaStreamHandler?.handleUpgrade).toBeTypeOf("function");
|
||||
expect(mediaStreamHandler?.sendAudio).toBeTypeOf("function");
|
||||
expect(mediaStreamHandler?.closeAll).toBeTypeOf("function");
|
||||
if (!mediaStreamHandler) {
|
||||
throw new Error("expected media stream handler");
|
||||
}
|
||||
expect(mediaStreamHandler.handleUpgrade).toBeTypeOf("function");
|
||||
expect(mediaStreamHandler.sendAudio).toBeTypeOf("function");
|
||||
expect(mediaStreamHandler.closeAll).toBeTypeOf("function");
|
||||
} finally {
|
||||
await server.stop();
|
||||
}
|
||||
|
||||
@@ -60,8 +60,6 @@ function sendFailure(error: string, threadId = "thread") {
|
||||
}
|
||||
|
||||
function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
||||
expect(typeof value).toBe("object");
|
||||
expect(value).not.toBeNull();
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error(`${label} was not an object`);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user