-
Notifications
You must be signed in to change notification settings - Fork 9.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b2c1693
commit 37f0731
Showing
5 changed files
with
52 additions
and
3 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
packages/@n8n/api-types/src/dto/ai/__tests__/ai-free-credits-request.dto.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { nanoId } from 'minifaker'; | ||
|
||
import { AiFreeCreditsRequestDto } from '../ai-free-credits-request.dto'; | ||
import 'minifaker/locales/en'; | ||
|
||
describe('AiChatRequestDto', () => { | ||
it('should succeed if projectId is a valid nanoid', () => { | ||
const validRequest = { | ||
projectId: nanoId.nanoid(), | ||
}; | ||
|
||
const result = AiFreeCreditsRequestDto.safeParse(validRequest); | ||
|
||
expect(result.success).toBe(true); | ||
}); | ||
|
||
it('should succeed if no projectId is sent', () => { | ||
const result = AiFreeCreditsRequestDto.safeParse({}); | ||
|
||
expect(result.success).toBe(true); | ||
}); | ||
|
||
it('should fail is projectId invalid value', () => { | ||
const validRequest = { | ||
projectId: '', | ||
}; | ||
|
||
const result = AiFreeCreditsRequestDto.safeParse(validRequest); | ||
|
||
expect(result.success).toBe(false); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
packages/@n8n/api-types/src/dto/ai/ai-free-credits-request.dto.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { z } from 'zod'; | ||
import { Z } from 'zod-class'; | ||
|
||
export class AiFreeCreditsRequestDto extends Z.class({ | ||
projectId: z.string().min(1).optional(), | ||
}) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters