/ clis / bilibili / utils.test.js
utils.test.js
 1  import { describe, expect, it } from 'vitest';
 2  import { resolveBvid } from './utils.js';
 3  describe('resolveBvid', () => {
 4      it('passes through a valid BV ID', async () => {
 5          expect(await resolveBvid('BV1MV9NBtENN')).toBe('BV1MV9NBtENN');
 6      });
 7      it('passes through BV ID with surrounding whitespace', async () => {
 8          expect(await resolveBvid('  BV1MV9NBtENN  ')).toBe('BV1MV9NBtENN');
 9      });
10      it('handles non-string input via String() coercion', async () => {
11          expect(await resolveBvid('BV123abc')).toBe('BV123abc');
12      });
13      it('rejects invalid input that cannot be resolved', async () => {
14          // A random string that b23.tv won't resolve — should timeout or fail
15          await expect(resolveBvid('not-a-valid-code-99999')).rejects.toThrow();
16      });
17  });