Skip to content

Commit c498c32

Browse files
committed
test
1 parent 18f7702 commit c498c32

14 files changed

Lines changed: 58 additions & 56 deletions

bot-core/parts/inspect.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test } from 'bun:test'
1+
import { describe, expect, test } from 'vitest'
22
import { hasRichParts } from './inspect'
33
import type { Part } from './model'
44

bot-core/parts/rolldown/parts-transform.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test } from 'bun:test'
1+
import { describe, expect, test } from 'vitest'
22
import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'
33
import path from 'node:path'
44
import { tmpdir } from 'node:os'

bot-core/parts/runtime.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, test } from 'bun:test'
1+
import { describe, expect, test } from 'vitest'
22
import { __parts } from './runtime'
33
import { parts } from './tag'
44
import { mentionUser, text } from './dsl'

bot-core/src/bridge/telegram/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ export const telegramBridge: BridgeDefinition<'telegram', 'telegram:ready', Tele
1111
event: 'telegram:ready',
1212
attach: (ctx, telegram, dispatch) => {
1313
// 使用 onFront 保证优先于命令/会话处理,从而不漏掉以 “/” 开头的消息
14-
const register =
14+
const add =
1515
(telegram.runtime.events.message as any).onFront?.bind(telegram.runtime.events.message) ??
1616
telegram.runtime.events.message.on.bind(telegram.runtime.events.message)
1717

18-
const unlisten = register((session: any, next: any) => {
18+
const unlisten = add((session: any, next: any) => {
1919
void (async () => {
2020
try {
2121
const normalized = await normalizeTelegramMessage(session)

bot-core/src/test/chat.commands.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from 'bun:test'
1+
import { describe, expect, it } from 'vitest'
22

33
import { cmd } from '../cmd'
44
import {

bot-core/src/test/outbound.payload.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from 'bun:test'
1+
import { describe, expect, it } from 'vitest'
22

33
import { normalizeReplyPayload } from '../outbound/payload'
44

bot-core/src/test/outbound.reply.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from 'bun:test'
1+
import { describe, expect, it } from 'vitest'
22

33
import { createReply } from '../adapter'
44
import type { OutboundOp, PlatformAdapter } from '../adapter'

bot-suite/src/core/commands/kit.install.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from 'bun:test'
1+
import { describe, expect, it } from 'vitest'
22

33
import type { Context } from '@pluxel/hmr'
44
import { CommandRegistry } from '../runtime/command-registry'

bot-suite/src/core/commands/kit.mcp.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, expect, it } from 'bun:test'
1+
import { describe, expect, it } from 'vitest'
22

33
import type { Context } from '@pluxel/hmr'
44

bot-suite/src/core/commands/kit.plugin-lifecycle.test.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { describe, expect, it } from 'bun:test'
1+
import '@pluxel/hmr/services'
2+
import { describe, expect, it } from 'vitest'
23

34
import { mkdir, rm } from 'node:fs/promises'
45
import { randomUUID } from 'node:crypto'
56
import path from 'node:path'
67

7-
import { BasePlugin, Plugin, withTestHost, type TestHost } from '@pluxel/core/test'
8+
import { BasePlugin, Plugin, withHost, type Host } from '@pluxel/test'
89
import { MikroOrmLibsql } from 'pluxel-plugin-mikro-orm'
910
import { KvMemory } from 'pluxel-plugin-kv'
1011
import { BotCore, type AnyMessage } from 'pluxel-plugin-bot-core'
@@ -16,7 +17,7 @@ import { ChatCommand } from './decorators'
1617
import { InstallChatCommands } from './install'
1718
import { cmd } from './draft'
1819

19-
type HostCtx = { host: TestHost; chatbots: Chatbots }
20+
type HostCtx = { host: Host; chatbots: Chatbots }
2021

2122
async function withChatbotsHost(
2223
plugins: any[],
@@ -27,14 +28,14 @@ async function withChatbotsHost(
2728
await mkdir(dataDir, { recursive: true })
2829
const dbName = path.join(dataDir, `chatbots-${randomUUID()}.sqlite`)
2930
try {
30-
await withTestHost(async (host) => {
31+
await withHost(async (host) => {
3132
const cfg = host.ctx.configService as unknown as { ready?: Promise<void> }
3233
if (cfg.ready) await cfg.ready
3334

34-
host.registerAll(MikroOrmLibsql, KvMemory, BotCore, Chatbots, ...plugins)
35+
host.add([MikroOrmLibsql, KvMemory, BotCore, Chatbots, ...plugins])
3536

36-
host.setConfig('MikroOrm', { config: { dbName, ensureSchemaOnInit: true } })
37-
host.setConfig('bot-core', {
37+
host.cfg('MikroOrm').set({ config: { dbName, ensureSchemaOnInit: true } })
38+
host.cfg('bot-core').set({
3839
config: {
3940
bridges: {
4041
kook: { enabled: false },
@@ -44,7 +45,7 @@ async function withChatbotsHost(
4445
debug: false,
4546
},
4647
})
47-
host.setConfig('bot-suite', {
48+
host.cfg('bot-suite').set({
4849
config: {
4950
cmdPrefix: '/',
5051
debug: false,
@@ -56,9 +57,9 @@ async function withChatbotsHost(
5657
},
5758
})
5859

59-
await host.commitStrict()
60+
await host.commit()
6061

61-
await fn({ host, chatbots: host.getOrThrow(Chatbots) })
62+
await fn({ host, chatbots: host.require(Chatbots) })
6263
})
6364
} finally {
6465
await rm(dbName, { force: true })
@@ -114,8 +115,8 @@ describe('chatbots cmdkit (plugin lifecycle integration)', () => {
114115
expect((r as any).val).toBe('pong')
115116
}
116117

117-
host.unregister(CmdTestA)
118-
await host.commitStrict()
118+
host.remove(CmdTestA)
119+
await host.commit()
119120

120121
expect(registry.list().some((x) => x.id === 'cmd-test-a.cmd.ping')).toBe(false)
121122
{
@@ -164,7 +165,7 @@ describe('chatbots cmdkit (plugin lifecycle integration)', () => {
164165
}
165166

166167
host.replace(CmdTestA_v1, CmdTestA_v2)
167-
await host.commitStrict()
168+
await host.commit()
168169

169170
const entries = registry.list().filter((x) => x.id === 'cmd-test-a.cmd.ping')
170171
expect(entries.length).toBe(1)

0 commit comments

Comments
 (0)