-
-
Notifications
You must be signed in to change notification settings - Fork 258
Expand file tree
/
Copy pathsession_clear_defaults.test.ts
More file actions
79 lines (67 loc) · 2.71 KB
/
session_clear_defaults.test.ts
File metadata and controls
79 lines (67 loc) · 2.71 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { sessionStore } from '../../../../utils/session-store.ts';
import plugin, { sessionClearDefaultsLogic } from '../session_clear_defaults.ts';
describe('session-clear-defaults tool', () => {
beforeEach(() => {
sessionStore.clear();
sessionStore.setDefaults({
scheme: 'MyScheme',
projectPath: '/path/to/proj.xcodeproj',
simulatorName: 'iPhone 16',
deviceId: 'DEVICE-123',
useLatestOS: true,
arch: 'arm64',
});
});
afterEach(() => {
sessionStore.clear();
});
describe('Export Field Validation (Literal)', () => {
it('should have correct name', () => {
expect(plugin.name).toBe('session-clear-defaults');
});
it('should have correct description', () => {
expect(plugin.description).toBe('Clear selected or all session defaults.');
});
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 clear specific keys when provided', async () => {
const result = await sessionClearDefaultsLogic({ keys: ['scheme', 'deviceId'] });
expect(result.isError).toBe(false);
expect(result.content[0].text).toContain('Session defaults cleared');
const current = sessionStore.getAll();
expect(current.scheme).toBeUndefined();
expect(current.deviceId).toBeUndefined();
expect(current.projectPath).toBe('/path/to/proj.xcodeproj');
expect(current.simulatorName).toBe('iPhone 16');
expect(current.useLatestOS).toBe(true);
expect(current.arch).toBe('arm64');
});
it('should clear all when all=true', async () => {
const result = await sessionClearDefaultsLogic({ all: true });
expect(result.isError).toBe(false);
expect(result.content[0].text).toBe('Session defaults cleared');
const current = sessionStore.getAll();
expect(Object.keys(current).length).toBe(0);
});
it('should clear all when no params provided', async () => {
const result = await sessionClearDefaultsLogic({});
expect(result.isError).toBe(false);
const current = sessionStore.getAll();
expect(Object.keys(current).length).toBe(0);
});
it('should validate keys enum', async () => {
const result = (await plugin.handler({ keys: ['invalid' as any] })) as any;
expect(result.isError).toBe(true);
expect(result.content[0].text).toContain('Parameter validation failed');
expect(result.content[0].text).toContain('keys');
});
});
});