mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 14:00:42 +00:00
test: require channel lifecycle starters
This commit is contained in:
@@ -17,6 +17,16 @@ vi.mock("./monitor-runtime.js", () => ({
|
||||
|
||||
const { nextcloudTalkGatewayAdapter } = await import("./gateway.js");
|
||||
|
||||
type NextcloudTalkStartAccount = NonNullable<typeof nextcloudTalkGatewayAdapter.startAccount>;
|
||||
|
||||
function requireStartAccount(): NextcloudTalkStartAccount {
|
||||
const startAccount = nextcloudTalkGatewayAdapter.startAccount;
|
||||
if (!startAccount) {
|
||||
throw new Error("Expected Nextcloud Talk gateway startAccount");
|
||||
}
|
||||
return startAccount;
|
||||
}
|
||||
|
||||
function buildAccount(): ResolvedNextcloudTalkAccount {
|
||||
return {
|
||||
accountId: "default",
|
||||
@@ -40,7 +50,7 @@ function mockStartedMonitor() {
|
||||
}
|
||||
|
||||
function startNextcloudAccount(abortSignal?: AbortSignal) {
|
||||
return nextcloudTalkGatewayAdapter.startAccount!(
|
||||
return requireStartAccount()(
|
||||
createStartAccountContext({
|
||||
account: buildAccount(),
|
||||
abortSignal,
|
||||
@@ -56,7 +66,7 @@ describe("nextcloud-talk startAccount lifecycle", () => {
|
||||
it("keeps startAccount pending until abort, then stops the monitor", async () => {
|
||||
const stop = mockStartedMonitor();
|
||||
const { abort, task, isSettled } = startAccountAndTrackLifecycle({
|
||||
startAccount: nextcloudTalkGatewayAdapter.startAccount!,
|
||||
startAccount: requireStartAccount(),
|
||||
account: buildAccount(),
|
||||
});
|
||||
await expectStopPendingUntilAbort({
|
||||
|
||||
@@ -48,6 +48,17 @@ vi.mock("./channel.runtime.js", () => ({
|
||||
|
||||
import { zaloPlugin } from "./channel.js";
|
||||
|
||||
type ZaloGateway = NonNullable<typeof zaloPlugin.gateway>;
|
||||
type ZaloStartAccount = NonNullable<ZaloGateway["startAccount"]>;
|
||||
|
||||
function requireStartAccount(): ZaloStartAccount {
|
||||
const startAccount = zaloPlugin.gateway?.startAccount;
|
||||
if (!startAccount) {
|
||||
throw new Error("Expected Zalo gateway startAccount");
|
||||
}
|
||||
return startAccount;
|
||||
}
|
||||
|
||||
function buildAccount(): ResolvedZaloAccount {
|
||||
return {
|
||||
accountId: "default",
|
||||
@@ -76,7 +87,7 @@ describe("zaloPlugin gateway.startAccount", () => {
|
||||
);
|
||||
|
||||
const { abort, patches, task, isSettled } = startAccountAndTrackLifecycle({
|
||||
startAccount: zaloPlugin.gateway!.startAccount!,
|
||||
startAccount: requireStartAccount(),
|
||||
account: buildAccount(),
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user