publish.test.js
1 import { describe, expect, it } from 'vitest'; 2 import { getRegistry } from '@jackwener/opencli/registry'; 3 import './publish.js'; 4 describe('douyin publish registration', () => { 5 it('registers the publish command', () => { 6 const registry = getRegistry(); 7 const cmds = [...registry.values()]; 8 const cmd = cmds.find((c) => c.site === 'douyin' && c.name === 'publish'); 9 expect(cmd).toBeDefined(); 10 expect(cmd?.args.some((a) => a.name === 'video')).toBe(true); 11 expect(cmd?.args.some((a) => a.name === 'title')).toBe(true); 12 expect(cmd?.args.some((a) => a.name === 'schedule')).toBe(true); 13 }); 14 it('has all expected args', () => { 15 const registry = getRegistry(); 16 const cmd = [...registry.values()].find((c) => c.site === 'douyin' && c.name === 'publish'); 17 const argNames = cmd?.args.map((a) => a.name) ?? []; 18 expect(argNames).toContain('video'); 19 expect(argNames).toContain('title'); 20 expect(argNames).toContain('schedule'); 21 expect(argNames).toContain('caption'); 22 expect(argNames).toContain('cover'); 23 expect(argNames).toContain('visibility'); 24 expect(argNames).toContain('allow_download'); 25 expect(argNames).toContain('collection'); 26 expect(argNames).toContain('activity'); 27 expect(argNames).toContain('poi_id'); 28 expect(argNames).toContain('poi_name'); 29 expect(argNames).toContain('hotspot'); 30 expect(argNames).toContain('no_safety_check'); 31 expect(argNames).toContain('sync_toutiao'); 32 }); 33 it('uses COOKIE strategy', () => { 34 const registry = getRegistry(); 35 const cmd = [...registry.values()].find((c) => c.site === 'douyin' && c.name === 'publish'); 36 expect(cmd?.strategy).toBe('cookie'); 37 }); 38 });