fix api build issues
This commit is contained in:
@@ -241,12 +241,15 @@ describe('API Contract Validation', () => {
|
||||
const dtoContent = await fs.readFile(dtoPath, 'utf-8');
|
||||
|
||||
if (propSchema.nullable) {
|
||||
// Nullable properties should be optional in TypeScript
|
||||
const propRegex = new RegExp(`${propName}\\??:\\s*([\\w\\[\\]<>|]+)\\s*;`);
|
||||
// Nullable properties should be optional OR include `| null` in the type.
|
||||
const propRegex = new RegExp(`${propName}(\\?)?:\\s*([^;]+);`);
|
||||
const match = dtoContent.match(propRegex);
|
||||
|
||||
if (match) {
|
||||
// Should include null in the type or be optional
|
||||
expect(match[1]).toContain('| null');
|
||||
const optionalMark = match[1];
|
||||
const typeText = match[2] ?? '';
|
||||
|
||||
expect(optionalMark === '?' || typeText.includes('| null')).toBe(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user