Skip to content

Commit

Permalink
Revert "chore: fix contains property check failing (#810)"
Browse files Browse the repository at this point in the history
This reverts commit df88e8b.
  • Loading branch information
ron-debajyoti authored Jul 11, 2022
1 parent df88e8b commit a5b4619
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/models/ConstrainedMetaModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@ export class ConstrainedObjectModel extends ConstrainedMetaModel {
*/
containsPropertyType<T>(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;
}
}
15 changes: 1 addition & 14 deletions test/models/ConstrainedMetaModel.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down

0 comments on commit a5b4619

Please sign in to comment.