本文整理汇总了TypeScript中class-transformer.plainToClass函数的典型用法代码示例。如果您正苦于以下问题:TypeScript plainToClass函数的具体用法?TypeScript plainToClass怎么用?TypeScript plainToClass使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了plainToClass函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: plainToClass
.then((data: object) => plainToClass(WorkflowStatus, data))
示例2: describe
describe('DevicesComponent', () => {
let comp: DevicesComponent;
let fixture: ComponentFixture<DevicesComponent>;
let service: DevicesService;
const testDeviceApis: AppApi[] = plainToClass(AppApi, [
{
name: 'app_name',
device_apis: [
{
name: 'type',
description: 'description',
fields: [
{
name: 'text field',
description: 'text field',
schema: {
type: 'string',
},
},
{
name: 'number field',
schema: {
type: 'integer',
},
},
{
name: 'boolean field',
schema: {
type: 'integer',
},
},
],
},
],
},
]);
const testDevices: Device[] = plainToClass(Device, [
{
id: 1,
name: 'name',
description: 'description',
type: 'type',
app_name: 'app_name',
fields: [
{
name: 'text field',
value: 'hello',
},
{
name: 'number field',
value: 5,
},
{
name: 'boolean field',
value: true,
},
],
},
]);
/**
* async beforeEach
*/
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
HttpModule,
NgbModule.forRoot(),
NgxDatatableModule,
JwtModule.forRoot({
config: {
tokenGetter: jwtTokenGetter,
blacklistedRoutes: ['/login', '/api/auth', '/api/auth/logout', '/api/auth/refresh']
}
}),
ToastrModule.forRoot({ positionClass: 'toast-bottom-right' })
// FormsModule,
// ReactiveFormsModule,
],
declarations: [DevicesComponent],
schemas: [NO_ERRORS_SCHEMA],
providers: [DevicesService, JwtInterceptor,
// Providing JwtInterceptor allow to inject JwtInterceptor manually into RefreshTokenInterceptor
{
provide: HTTP_INTERCEPTORS,
useExisting: JwtInterceptor,
multi: true
},
{
provide: HTTP_INTERCEPTORS,
useClass: RefreshTokenInterceptor,
multi: true
}],
})
.compileComponents();
}));
/**
//.........这里部分代码省略.........