forked from wangziqi/gongxue-base
feat: add CASL authorization and AI configuration
This commit is contained in:
17
apps/server/src/notifications/dto/notification.dto.spec.ts
Normal file
17
apps/server/src/notifications/dto/notification.dto.spec.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import 'reflect-metadata';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { validate } from 'class-validator';
|
||||
import { NotificationQueryDto } from './notification.dto';
|
||||
|
||||
describe('NotificationQueryDto', () => {
|
||||
it('converts numeric query-string values before integer validation', async () => {
|
||||
const dto = plainToInstance(NotificationQueryDto, {
|
||||
after: '42',
|
||||
limit: '20',
|
||||
});
|
||||
|
||||
await expect(validate(dto)).resolves.toEqual([]);
|
||||
expect(dto.after).toBe(42);
|
||||
expect(dto.limit).toBe(20);
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
import { IsString, IsNotEmpty, IsOptional, IsArray, IsInt } from 'class-validator';
|
||||
import { Type } from 'class-transformer';
|
||||
|
||||
export class CreateNotificationDto {
|
||||
@IsArray()
|
||||
@@ -24,10 +25,12 @@ export class CreateNotificationDto {
|
||||
|
||||
export class NotificationQueryDto {
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
after?: number;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user