|
1 | 1 | import { describe, it, expect } from 'vitest'; |
2 | 2 | import { isTerminal } from '../../../src/experimental/tasks/interfaces.js'; |
3 | 3 | import type { Task } from '../../../src/types.js'; |
| 4 | +import { TaskCreationParamsSchema } from '../../../src/types.js'; |
4 | 5 |
|
5 | 6 | describe('Task utility functions', () => { |
6 | 7 | describe('isTerminal', () => { |
@@ -115,3 +116,30 @@ describe('Task Schema Validation', () => { |
115 | 116 | }); |
116 | 117 | }); |
117 | 118 | }); |
| 119 | + |
| 120 | +describe('TaskCreationParams Schema Validation', () => { |
| 121 | + it('should accept ttl as a number', () => { |
| 122 | + const result = TaskCreationParamsSchema.safeParse({ ttl: 60000 }); |
| 123 | + expect(result.success).toBe(true); |
| 124 | + }); |
| 125 | + |
| 126 | + it('should accept missing ttl (optional)', () => { |
| 127 | + const result = TaskCreationParamsSchema.safeParse({}); |
| 128 | + expect(result.success).toBe(true); |
| 129 | + }); |
| 130 | + |
| 131 | + it('should reject null ttl (not allowed in request, only response)', () => { |
| 132 | + const result = TaskCreationParamsSchema.safeParse({ ttl: null }); |
| 133 | + expect(result.success).toBe(false); |
| 134 | + }); |
| 135 | + |
| 136 | + it('should accept pollInterval as a number', () => { |
| 137 | + const result = TaskCreationParamsSchema.safeParse({ pollInterval: 1000 }); |
| 138 | + expect(result.success).toBe(true); |
| 139 | + }); |
| 140 | + |
| 141 | + it('should accept both ttl and pollInterval', () => { |
| 142 | + const result = TaskCreationParamsSchema.safeParse({ ttl: 60000, pollInterval: 1000 }); |
| 143 | + expect(result.success).toBe(true); |
| 144 | + }); |
| 145 | +}); |
0 commit comments