Dev Build / cleanup (push) Waiting to run
Dev Build / typecheck (push) Waiting to run
Publish MCP to npm / Build, test, and publish MCP (push) Waiting to run
Publish SDK to npm / Build, test, and publish SDK (push) Waiting to run
Sync action catalog to docs / sync (push) Waiting to run
Publish UI to npm / Build and publish UI (push) Waiting to run
Build and Release / preflight (push) Waiting to run
64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
import { IdentityService } from '@snowluma/protocol/identity-service';
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
import { SysFaceStore, type SysFaceCatalogStorage } from '@snowluma/protocol/sys-face-store';
|
|
import { BridgeManager } from '../src/bridge/manager';
|
|
import { bindSystemFaceCatalog } from '../src/sys-face-catalog';
|
|
|
|
const storage: SysFaceCatalogStorage = {
|
|
load: async () => null,
|
|
save: async () => {},
|
|
};
|
|
|
|
describe('bindSystemFaceCatalog', () => {
|
|
let manager: BridgeManager;
|
|
|
|
beforeEach(() => {
|
|
vi.spyOn(IdentityService, 'openForUin').mockImplementation((uin) =>
|
|
IdentityService.memory(uin),
|
|
);
|
|
manager = new BridgeManager();
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await manager.dispose();
|
|
vi.restoreAllMocks();
|
|
});
|
|
|
|
it('starts one shared catalog prewarm from the first logged-in account', async () => {
|
|
let fetches = 0;
|
|
const store = new SysFaceStore({
|
|
fetchCatalog: async () => {
|
|
fetches += 1;
|
|
return [
|
|
{
|
|
packName: '经典',
|
|
emojis: [
|
|
{
|
|
qSid: '14',
|
|
qDes: '/微笑',
|
|
emCode: '14',
|
|
qCid: null,
|
|
aniStickerType: null,
|
|
aniStickerPackId: null,
|
|
aniStickerId: null,
|
|
url: null,
|
|
emojiNameAlias: [],
|
|
aniStickerWidth: null,
|
|
aniStickerHeight: null,
|
|
},
|
|
],
|
|
},
|
|
];
|
|
},
|
|
});
|
|
bindSystemFaceCatalog(manager, { store, storage });
|
|
|
|
const packetSender = { sendPacket: vi.fn() } as never;
|
|
manager.onHookLogin(101, '10001', packetSender);
|
|
manager.onHookLogin(202, '20002', packetSender);
|
|
|
|
await vi.waitFor(() => expect(fetches).toBe(1));
|
|
expect(store.lookup(14)?.qDes).toBe('/微笑');
|
|
});
|
|
});
|