-
-
Notifications
You must be signed in to change notification settings - Fork 265
Expand file tree
/
Copy pathsession_set_defaults.test.ts
More file actions
60 lines (50 loc) · 2.02 KB
/
session_set_defaults.test.ts
File metadata and controls
60 lines (50 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { describe, it, expect, beforeEach } from 'vitest';
import { sessionStore } from '../../../../utils/session-store.ts';
import plugin, { sessionSetDefaultsLogic } from '../session_set_defaults.ts';
describe('session-set-defaults tool', () => {
beforeEach(() => {
sessionStore.clear();
});
describe('Export Field Validation (Literal)', () => {
it('should have correct name', () => {
expect(plugin.name).toBe('session-set-defaults');
});
it('should have correct description', () => {
expect(plugin.description).toBe(
'Set the session defaults needed by many tools. Most tools require one or more session defaults to be set before they can be used. Agents should set the relevent defaults at the beginning of a session.',
);
});
it('should have handler function', () => {
expect(typeof plugin.handler).toBe('function');
});
it('should have schema object', () => {
expect(plugin.schema).toBeDefined();
expect(typeof plugin.schema).toBe('object');
});
});
describe('Handler Behavior', () => {
it('should set provided defaults and return updated state', async () => {
const result = await sessionSetDefaultsLogic({
scheme: 'MyScheme',
simulatorName: 'iPhone 16',
useLatestOS: true,
arch: 'arm64',
});
expect(result.isError).toBe(false);
expect(result.content[0].text).toContain('Defaults updated:');
const current = sessionStore.getAll();
expect(current.scheme).toBe('MyScheme');
expect(current.simulatorName).toBe('iPhone 16');
expect(current.useLatestOS).toBe(true);
expect(current.arch).toBe('arm64');
});
it('should validate parameter types via Zod', async () => {
const result = await plugin.handler({
useLatestOS: 'yes' as unknown as boolean,
});
expect(result.isError).toBe(true);
expect(result.content[0].text).toContain('Parameter validation failed');
expect(result.content[0].text).toContain('useLatestOS');
});
});
});