From a5b4619bcb3adb3d73dc4762d0191a63c607ebaa Mon Sep 17 00:00:00 2001 From: Debajyoti Halder Date: Mon, 11 Jul 2022 21:02:36 +0530 Subject: [PATCH] Revert "chore: fix contains property check failing (#810)" This reverts commit df88e8be5a01b6016c5b309a165cb25353d5d6a3. --- src/models/ConstrainedMetaModel.ts | 4 ++-- test/models/ConstrainedMetaModel.spec.ts | 15 +-------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/models/ConstrainedMetaModel.ts b/src/models/ConstrainedMetaModel.ts index 0a14957959..38ff6e259d 100644 --- a/src/models/ConstrainedMetaModel.ts +++ b/src/models/ConstrainedMetaModel.ts @@ -202,8 +202,8 @@ export class ConstrainedObjectModel extends ConstrainedMetaModel { */ containsPropertyType(propertyType: { new(...args: any[]): T }) : boolean { const foundPropertiesWithType = Object.values(this.properties).filter((property) => { - return property.property instanceof propertyType; + return property instanceof propertyType; }); - return foundPropertiesWithType.length !== 0; + return foundPropertiesWithType.length === 0; } } diff --git a/test/models/ConstrainedMetaModel.spec.ts b/test/models/ConstrainedMetaModel.spec.ts index a67be9367f..48edbe4e60 100644 --- a/test/models/ConstrainedMetaModel.spec.ts +++ b/test/models/ConstrainedMetaModel.spec.ts @@ -1,8 +1,7 @@ import { constrainMetaModel } from '../../src/helpers'; -import { AnyModel, ArrayModel, BooleanModel, ConstrainedArrayModel, ConstrainedBooleanModel, ConstrainedDictionaryModel, ConstrainedEnumModel, ConstrainedObjectModel, ConstrainedObjectPropertyModel, ConstrainedReferenceModel, ConstrainedStringModel, ConstrainedTupleModel, ConstrainedUnionModel, DictionaryModel, EnumModel, EnumValueModel, FloatModel, IntegerModel, ObjectModel, ObjectPropertyModel, ReferenceModel, StringModel, TupleModel, TupleValueModel, UnionModel } from '../../src/models'; +import { AnyModel, ArrayModel, BooleanModel, ConstrainedArrayModel, ConstrainedDictionaryModel, ConstrainedEnumModel, ConstrainedObjectModel, ConstrainedReferenceModel, ConstrainedTupleModel, ConstrainedUnionModel, DictionaryModel, EnumModel, EnumValueModel, FloatModel, IntegerModel, ObjectModel, ObjectPropertyModel, ReferenceModel, StringModel, TupleModel, TupleValueModel, UnionModel } from '../../src/models'; import { mockedConstraints, mockedTypeMapping } from '../TestUtils/TestConstrainer'; - describe('ConstrainedMetaModel', () => { describe('ReferenceModel', () => { test('should return no dependencies', () => { @@ -121,18 +120,6 @@ describe('ConstrainedMetaModel', () => { expect(dependencies).toHaveLength(1); expect(dependencies[0]).toEqual(model.properties['reference'].property); }); - - describe('containsPropertyType', () => { - test('should find present property type and those who are not', () => { - const stringModel = new ConstrainedStringModel('', undefined, ''); - const stringObjectPropertyModel = new ConstrainedObjectPropertyModel('string', '', false, stringModel); - const rawModel = new ConstrainedObjectModel('test', undefined, '', { - string: stringObjectPropertyModel - }); - expect(rawModel.containsPropertyType(ConstrainedStringModel)).toEqual(true); - expect(rawModel.containsPropertyType(ConstrainedBooleanModel)).toEqual(false); - }); - }); }); describe('EnumModel', () => { test('should return no dependencies', () => {