@byline/core 6.7.1 → 6.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { defineCollection } from '../../@types/collection-types.js';
3
+ import { createCollectionSchemas } from './builder.js';
4
+ const collection = defineCollection({
5
+ path: 'review-probe', labels: { singular: 'Probe', plural: 'Probes' },
6
+ fields: [{ name: 'choice', type: 'select', options: [{ label: 'A', value: 'a' }] }],
7
+ });
8
+ const schemas = createCollectionSchemas(collection);
9
+ const doc = {
10
+ id: '550e8400-e29b-41d4-a716-446655440000', status: 'draft',
11
+ createdAt: '2026-09-16T12:00:00.000Z', updatedAt: '2026-09-16T12:00:00.000Z',
12
+ fields: { choice: 'a' },
13
+ };
14
+ const response = {
15
+ docs: [doc], meta: { page: 1, pageSize: 10, total: 1, totalPages: 1 },
16
+ included: { collection: { id: 'review-probe', path: collection.path, labels: collection.labels } },
17
+ };
18
+ describe('review comparison: invalid values reject a read response', () => {
19
+ it('accepts a valid response', () => expect(schemas.list.safeParse(response).success).toBe(true));
20
+ it('rejects the response if one document has an invalid select', () => {
21
+ expect(schemas.list.safeParse({ ...response, docs: [doc, { ...doc, fields: { choice: 'bogus' } }] }).success).toBe(false);
22
+ });
23
+ it('rejects the response if one document has an invalid status', () => {
24
+ expect(schemas.list.safeParse({ ...response, docs: [doc, { ...doc, status: 'bogus' }] }).success).toBe(false);
25
+ });
26
+ });