Files
wehub-resource-sync 9b395f5cc3
E2E Headed Chrome / e2e-headed (macos-15) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (ubuntu-latest) (push) Has been cancelled
E2E Headed Chrome / e2e-headed (windows-latest) (push) Has been cancelled
CI / build (macos-latest) (push) Has been cancelled
CI / build (ubuntu-latest) (push) Has been cancelled
CI / build (windows-latest) (push) Has been cancelled
CI / unit-test (push) Has been cancelled
CI / bun-test (push) Has been cancelled
CI / adapter-test (push) Has been cancelled
CI / smoke-test (macos-latest) (push) Has been cancelled
CI / smoke-test (ubuntu-latest) (push) Has been cancelled
Security Audit / audit (push) Has been cancelled
Build Chrome Extension / build (push) Has been cancelled
Trigger Website Rebuild (Docs Updated) / dispatch (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:39:48 +08:00

56 lines
2.1 KiB
JavaScript

import { beforeEach, describe, expect, it, vi } from 'vitest';
const { browserFetchMock } = vi.hoisted(() => ({
browserFetchMock: vi.fn(),
}));
vi.mock('./_shared/browser-fetch.js', () => ({
browserFetch: browserFetchMock,
}));
import { getRegistry } from '@jackwener/opencli/registry';
import './activities.js';
describe('douyin activities registration', () => {
beforeEach(() => {
browserFetchMock.mockReset();
});
it('registers the activities command', () => {
const registry = getRegistry();
const cmd = [...registry.values()].find(c => c.site === 'douyin' && c.name === 'activities');
expect(cmd).toBeDefined();
});
it('has expected columns', () => {
const registry = getRegistry();
const cmd = [...registry.values()].find(c => c.site === 'douyin' && c.name === 'activities');
expect(cmd?.columns).toContain('activity_id');
expect(cmd?.columns).toContain('title');
expect(cmd?.columns).toContain('end_time');
});
it('uses COOKIE strategy', () => {
const registry = getRegistry();
const cmd = [...registry.values()].find(c => c.site === 'douyin' && c.name === 'activities');
expect(cmd?.strategy).toBe('cookie');
});
it('maps the current activity payload shape returned by creator center', async () => {
const registry = getRegistry();
const cmd = [...registry.values()].find(c => c.site === 'douyin' && c.name === 'activities');
expect(cmd?.func).toBeDefined();
if (!cmd?.func)
throw new Error('douyin activities command not registered');
browserFetchMock.mockResolvedValueOnce({
activity_list: [
{
activity_id: '200',
activity_name: '超会玩派对',
show_end_time: '2026.05.31',
},
],
});
const rows = await cmd.func({}, {});
expect(rows).toEqual([
{
activity_id: '200',
title: '超会玩派对',
end_time: '2026.05.31',
},
]);
});
});