[v2] Minor task-related refactors (#1758)
Co-authored-by: Luca Chang <lucalc@amazon.com> Co-authored-by: Luca Chang <131398524+LucaButBoring@users.noreply.github.com> Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
This commit is contained in:
parent
cc9c9d19a1
commit
e86b1835cc
1 changed files with 108 additions and 18 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { isTerminal } from '@modelcontextprotocol/core';
|
||||
import type { Task } from '@modelcontextprotocol/server';
|
||||
import type { Task } from '@modelcontextprotocol/core';
|
||||
import { isTerminal, TaskCreationParamsSchema } from '@modelcontextprotocol/core';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('Task utility functions', () => {
|
||||
|
|
@ -115,3 +115,30 @@ describe('Task Schema Validation', () => {
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('TaskCreationParams Schema Validation', () => {
|
||||
it('should accept ttl as a number', () => {
|
||||
const result = TaskCreationParamsSchema.safeParse({ ttl: 60_000 });
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should accept missing ttl (optional)', () => {
|
||||
const result = TaskCreationParamsSchema.safeParse({});
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should reject null ttl (not allowed in request, only response)', () => {
|
||||
const result = TaskCreationParamsSchema.safeParse({ ttl: null });
|
||||
expect(result.success).toBe(false);
|
||||
});
|
||||
|
||||
it('should accept pollInterval as a number', () => {
|
||||
const result = TaskCreationParamsSchema.safeParse({ pollInterval: 1000 });
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
|
||||
it('should accept both ttl and pollInterval', () => {
|
||||
const result = TaskCreationParamsSchema.safeParse({ ttl: 60_000, pollInterval: 1000 });
|
||||
expect(result.success).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue