/ clis / cnki / search.test.js
search.test.js
 1  import { describe, expect, it } from 'vitest';
 2  import { getRegistry } from '@jackwener/opencli/registry';
 3  import './search.js';
 4  describe('cnki search command', () => {
 5      const command = getRegistry().get('cnki/search');
 6      it('registers the command', () => {
 7          expect(command).toBeDefined();
 8          expect(command.site).toBe('cnki');
 9          expect(command.name).toBe('search');
10      });
11      it('rejects empty queries before browser navigation', async () => {
12          const page = { goto: async () => undefined };
13          await expect(command.func(page, { query: '   ' })).rejects.toMatchObject({
14              name: 'ArgumentError',
15              code: 'ARGUMENT',
16          });
17      });
18  });