Skip to content

Commit

Permalink
Add a test case for epiphone#78
Browse files Browse the repository at this point in the history
  • Loading branch information
epiphone committed May 29, 2022
1 parent a930cb9 commit b6bcbfc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions __tests__/exclude.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// tslint:disable:no-submodule-imports
import { Exclude } from 'class-transformer'
import { Allow, IsString } from 'class-validator'
import { Allow, IsOptional, IsString } from 'class-validator'
import { validationMetadatasToSchemas } from '../src'
const { defaultMetadataStorage } = require('class-transformer/cjs/storage')

Expand All @@ -11,6 +11,9 @@ class Parent {
@Exclude()
@Allow()
inheritedInternal: unknown

@Allow()
excludedInUser: unknown
}

// @ts-ignore unused
Expand All @@ -21,6 +24,10 @@ class User extends Parent {
@Exclude()
@Allow()
internal: unknown

@Exclude()
@IsOptional()
excludedInUser: unknown
}

describe('Exclude() decorator', () => {
Expand All @@ -32,10 +39,11 @@ describe('Exclude() decorator', () => {
expect(schema).toEqual({
Parent: {
properties: {
excludedInUser: {},
inherited: {},
},
type: 'object',
required: ['inherited'],
required: ['inherited', 'excludedInUser'],
},
User: {
properties: {
Expand Down

0 comments on commit b6bcbfc

Please sign in to comment.