Skip to content

Commit 6adb0db

Browse files
committed
test(objectql): assert the control refusals' code and sentence one by one
Claude-Session: https://claude.ai/code/session_017VaLJnYwhPsanVCe9dMCJU Co-authored-by: Claude <noreply@anthropic.com>
1 parent 238763f commit 6adb0db

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎packages/objectql/src/validation/record-validator.test.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,12 +1406,18 @@ describe('[#20846] validateRecord — a readable date / datetime outside its yea
14061406
});
14071407

14081408
it('CONTROL — a value that is not readable, or a number, keeps the ISO sentence', () => {
1409-
expect(refusal({ at: 'not-a-date' })).toMatchObject({ code: 'invalid_date', message: 'At must be a valid datetime (ISO-8601)' });
1410-
expect(refusal({ due: 'not-a-date' })).toMatchObject({ code: 'invalid_date', message: 'Due must be a valid date (ISO-8601)' });
14111409
// Epoch milliseconds in year 10000: never a written value, whatever its year.
14121410
const y10000 = Date.parse('+010000-01-01T00:00:00.000Z');
1413-
expect(refusal({ at: y10000 })).toMatchObject({ code: 'invalid_date', message: 'At must be a valid datetime (ISO-8601)' });
1414-
expect(refusal({ due: y10000 })).toMatchObject({ code: 'invalid_date', message: 'Due must be a valid date (ISO-8601)' });
1411+
for (const [data, sentence] of [
1412+
[{ at: 'not-a-date' }, 'At must be a valid datetime (ISO-8601)'],
1413+
[{ due: 'not-a-date' }, 'Due must be a valid date (ISO-8601)'],
1414+
[{ at: y10000 }, 'At must be a valid datetime (ISO-8601)'],
1415+
[{ due: y10000 }, 'Due must be a valid date (ISO-8601)'],
1416+
] as const) {
1417+
const f = refusal(data);
1418+
expect(f.code, JSON.stringify(data)).toBe('invalid_date');
1419+
expect(f.message, JSON.stringify(data)).toBe(sentence);
1420+
}
14151421
});
14161422

14171423
it('CONTROL — a readable value inside the years, refused for its spelling, keeps the ISO sentence', () => {

0 commit comments

Comments
 (0)