Skip to content

Commit 96e9f95

Browse files
committed
add tests for annotations
1 parent 959d235 commit 96e9f95

File tree

1 file changed

+59
-4
lines changed

1 file changed

+59
-4
lines changed

src/types.test.ts

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,75 +95,130 @@ describe('Types', () => {
9595

9696
describe('ContentBlock', () => {
9797
test('should validate text content', () => {
98+
const mockDate = new Date().toISOString();
9899
const textContent = {
99100
type: 'text',
100-
text: 'Hello, world!'
101+
text: 'Hello, world!',
102+
annotations: {
103+
audience: ['user'],
104+
priority: 0.5,
105+
lastModified: mockDate
106+
}
101107
};
102108

103109
const result = ContentBlockSchema.safeParse(textContent);
104110
expect(result.success).toBe(true);
105111
if (result.success) {
106112
expect(result.data.type).toBe('text');
113+
expect(result.data.annotations).toEqual({
114+
audience: ['user'],
115+
priority: 0.5,
116+
lastModified: mockDate
117+
});
107118
}
108119
});
109120

110121
test('should validate image content', () => {
122+
const mockDate = new Date().toISOString();
111123
const imageContent = {
112124
type: 'image',
113125
data: 'aGVsbG8=', // base64 encoded "hello"
114-
mimeType: 'image/png'
126+
mimeType: 'image/png',
127+
annotations: {
128+
audience: ['user'],
129+
priority: 0.5,
130+
lastModified: mockDate
131+
}
115132
};
116133

117134
const result = ContentBlockSchema.safeParse(imageContent);
118135
expect(result.success).toBe(true);
119136
if (result.success) {
120137
expect(result.data.type).toBe('image');
138+
expect(result.data.annotations).toEqual({
139+
audience: ['user'],
140+
priority: 0.5,
141+
lastModified: mockDate
142+
});
121143
}
122144
});
123145

124146
test('should validate audio content', () => {
147+
const mockDate = new Date().toISOString();
125148
const audioContent = {
126149
type: 'audio',
127150
data: 'aGVsbG8=', // base64 encoded "hello"
128-
mimeType: 'audio/mp3'
151+
mimeType: 'audio/mp3',
152+
annotations: {
153+
audience: ['user'],
154+
priority: 0.5,
155+
lastModified: mockDate
156+
}
129157
};
130158

131159
const result = ContentBlockSchema.safeParse(audioContent);
132160
expect(result.success).toBe(true);
133161
if (result.success) {
134162
expect(result.data.type).toBe('audio');
163+
expect(result.data.annotations).toEqual({
164+
audience: ['user'],
165+
priority: 0.5,
166+
lastModified: mockDate
167+
});
135168
}
136169
});
137170

138171
test('should validate resource link content', () => {
172+
const mockDate = new Date().toISOString();
139173
const resourceLink = {
140174
type: 'resource_link',
141175
uri: 'file:///path/to/file.txt',
142176
name: 'file.txt',
143-
mimeType: 'text/plain'
177+
mimeType: 'text/plain',
178+
annotations: {
179+
audience: ['user'],
180+
priority: 0.5,
181+
lastModified: new Date().toISOString()
182+
}
144183
};
145184

146185
const result = ContentBlockSchema.safeParse(resourceLink);
147186
expect(result.success).toBe(true);
148187
if (result.success) {
149188
expect(result.data.type).toBe('resource_link');
189+
expect(result.data.annotations).toEqual({
190+
audience: ['user'],
191+
priority: 0.5,
192+
lastModified: mockDate
193+
});
150194
}
151195
});
152196

153197
test('should validate embedded resource content', () => {
198+
const mockDate = new Date().toISOString();
154199
const embeddedResource = {
155200
type: 'resource',
156201
resource: {
157202
uri: 'file:///path/to/file.txt',
158203
mimeType: 'text/plain',
159204
text: 'File contents'
205+
},
206+
annotations: {
207+
audience: ['user'],
208+
priority: 0.5,
209+
lastModified: mockDate
160210
}
161211
};
162212

163213
const result = ContentBlockSchema.safeParse(embeddedResource);
164214
expect(result.success).toBe(true);
165215
if (result.success) {
166216
expect(result.data.type).toBe('resource');
217+
expect(result.data.annotations).toEqual({
218+
audience: ['user'],
219+
priority: 0.5,
220+
lastModified: mockDate
221+
});
167222
}
168223
});
169224
});

0 commit comments

Comments
 (0)