Skip to content

Commit 478fefe

Browse files
committed
fix: tests
1 parent bb0da3e commit 478fefe

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/unit/tools.utils.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ describe('shortenProperties', () => {
356356

357357
it('should shorten enum values if they exceed the limit', () => {
358358
// Create an enum with many values to exceed the character limit
359-
const enumValues = Array.from({ length: 50 }, (_, i) => `enum-value-${i}`);
359+
const value = 'enum-value-';
360+
const enumValues = Array.from({ length: Math.ceil(ACTOR_ENUM_MAX_LENGTH / value.length) + 1 }, (_, i) => `${value}${i}`);
360361
const properties: Record<string, ISchemaProperties> = {
361362
prop1: {
362363
type: 'string',
@@ -371,7 +372,7 @@ describe('shortenProperties', () => {
371372
// Check that enum was shortened
372373
expect(result.prop1.enum).toBeDefined();
373374
if (result.prop1.enum) {
374-
expect(result.prop1.enum.length).toBeLessThan(30);
375+
expect(result.prop1.enum.length).toBeLessThan(enumValues.length);
375376
const totalEnumLen = result.prop1.enum.reduce((sum, v) => sum + v.length, 0);
376377
expect(totalEnumLen).toBeLessThanOrEqual(ACTOR_ENUM_MAX_LENGTH);
377378

@@ -385,7 +386,8 @@ describe('shortenProperties', () => {
385386

386387
it('should shorten items.enum values if they exceed the limit', () => {
387388
// Create an enum with many values to exceed the character limit
388-
const enumValues = Array.from({ length: 50 }, (_, i) => `enum-value-${i}`);
389+
const value = 'enum-value-';
390+
const enumValues = Array.from({ length: Math.ceil(ACTOR_ENUM_MAX_LENGTH / value.length) + 1 }, (_, i) => `${value}${i}`);
389391
const properties: Record<string, ISchemaProperties> = {
390392
prop1: {
391393
type: 'array',
@@ -889,8 +891,8 @@ describe('inferArrayItemsTypeIfMissing', () => {
889891
describe('shortenEnum', () => {
890892
it('shorten enum list', () => {
891893
const enumList: string[] = [];
892-
const wordLength = 10;
893-
const wordCount = 30;
894+
const wordLength = 100;
895+
const wordCount = ACTOR_ENUM_MAX_LENGTH / wordLength + 1; // exceed the limit
894896

895897
for (let i = 0; i < wordCount; i++) {
896898
enumList.push('a'.repeat(wordLength));

0 commit comments

Comments
 (0)