Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import type { ByteplusDoc } from './byteplus-pricing.ts'
4import { parseByteplusMcpSupport } from './byteplus-tools.ts'
5
6/** A one-table model-list document, in the page's zone layout. */
7function doc(rows: Array<Array<string>>): ByteplusDoc {
8 const data: ByteplusDoc['data'] = {
9 '0': { ops: [{ insert: '*', attributes: { aceTable: 'rows cols' } }] },
10 rows: { ops: rows.map((_, r) => ({ insert: { id: `r${String(r)}` } })) },
11 cols: {
12 ops: (rows[0] ?? []).map((_, c) => ({ insert: { id: `c${String(c)}` } })),
13 },
14 }
15 rows.forEach((cells, r) => {
16 cells.forEach((text, c) => {
17 data[`xr${String(r)}xc${String(c)}`] = { ops: [{ insert: `${text}\n` }] }
18 })
19 })
20 return { data }
21}
22
23// The model list's Tool use table as served on 2026-10-22, cut down.
24const HEADER = [
25 'Model ID',
26 'Function calling\nResponses API & Chat API',
27 'MCP\nResponses API',
28]
29
30describe('parseByteplusMcpSupport', () => {
31 it('reads each row of the Tool use table', () => {
32 const support = parseByteplusMcpSupport(
33 doc([
34 HEADER,
35 ['dola-seed-2-1-turbo-260628', 'Supported', 'Supported'],
36 ['seed-2-0-code-preview-260328', 'Supported', 'Not Supported'],
37 [
38 'seed-1-8-251228 Retiring\n(Recommended replacement: seed-2-0-lite-260428)',
39 'Supported',
40 'Supported',
41 ],
42 ]),
43 )
44 expect([...support]).toEqual([
45 ['dola-seed-2-1-turbo-260628', true],
46 ['seed-2-0-code-preview-260328', false],
47 ['seed-1-8-251228', true],
48 ])
49 })
50
51 it('reads the Yes / No wording past a Provider column', () => {
52 // The Tool use table as served on 2026-10-23, cut down.
53 const support = parseByteplusMcpSupport(
54 doc([
55 ['Provider', 'Model ID', 'Function calling', 'MCP'],
56 ['ByteDance', 'dola-seed-2-1-turbo-260628', 'Yes', 'Yes'],
57 ['', 'seed-2-0-code-preview-260328', 'Yes', 'No'],
58 ['Z.ai', 'glm-5-2-260617', 'Yes', 'Yes'],
59 ]),
60 )
61 expect([...support]).toEqual([
62 ['dola-seed-2-1-turbo-260628', true],
63 ['seed-2-0-code-preview-260328', false],
64 ['glm-5-2-260617', true],
65 ])
66 })
67
68 it('throws on a missing table or a cell it cannot read', () => {
69 expect(() =>
70 parseByteplusMcpSupport(doc([['Model ID', 'Capabilities']])),
71 ).toThrow('no Tool use table')
72 expect(() =>
73 parseByteplusMcpSupport(doc([HEADER, ['m-1', 'Supported', 'Beta']])),
74 ).toThrow('unread Tool use row')
75 })
76})