import { describe, it, after } from 'node:test'
import assert from 'node:assert'
import { TOOL_CONFIG } from '../src/config/api.ts'
import type { McpToolResponse } from './types.ts'
import type { Video } from '../src/types/index.ts'
import { createTestClient, parseToolResponse } from './helpers.ts'
describe('Videos API Tests', async () => {
const client = await createTestClient()
after(async () => {
await client.close()
})
it('should get a list of videos with default pagination', async () => {
const result = await client.callTool({
name: TOOL_CONFIG.videos.name,
arguments: {}
}) as McpToolResponse
assert.ok(result.content[0]?.text.includes('Videos Results'))
const data = parseToolResponse(result)
assert.ok(data.totalCount > 0)
assert.ok(Array.isArray(data.videos))
assert.equal(data.videos.length, 10) // Default limit
})
it('should get a limited number of videos', async () => {
const limit = 2
const result = await client.callTool({
name: TOOL_CONFIG.videos.name,
arguments: { limit }
}) as McpToolResponse
const data = parseToolResponse(result)
assert.equal(data.videos.length, limit)
})
it('should filter videos by language', async () => {
const result = await client.callTool({
name: TOOL_CONFIG.videos.name,
arguments: {
language: 'en-us',
limit: 5
}
}) as McpToolResponse
const data = parseToolResponse(result)
assert.ok(data.videos.every((video: Video) => video.language === 'en-us'))
})
})