Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Selman <[email protected]>
  • Loading branch information
dselman committed Jan 5, 2024
1 parent a1548b9 commit d929ed8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 14 deletions.
1 change: 0 additions & 1 deletion MAINTAINERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ The maintainers are listed in alphabetical order.

- Matt Roberts ([mttrbrts](https://github.com/mttrbrts))
- Daniel Selman ([dselman](https://github.com/dselman))
- Jerome Simeon ([jeromesimeon](https://github.com/jeromesimeon))

## License <a name="license"></a>
Accord Project Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at http://creativecommons.org/licenses/by/4.0/.
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/concerto-analysis/src/compare-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* limitations under the License.
*/

import { ClassDeclaration, Declaration, EnumValueDeclaration, Field, MapDeclaration, ScalarDeclaration, NumberValidator, Property, RelationshipDeclaration, StringValidator, Validator } from '@accordproject/concerto-core';
import { ClassDeclaration, Declaration, EnumValue, Field, MapDeclaration, ScalarDeclaration, NumberValidator, Property, RelationshipProperty, StringValidator, Validator } from '@accordproject/concerto-core';

export function getDeclarationType(declaration: Declaration) {
if (declaration instanceof ClassDeclaration) {
Expand Down Expand Up @@ -44,9 +44,9 @@ export function getDeclarationType(declaration: Declaration) {
export function getPropertyType(property: Property) {
if (property instanceof Field) {
return 'field';
} else if (property instanceof RelationshipDeclaration) {
} else if (property instanceof RelationshipProperty) {
return 'relationship';
} else if (property instanceof EnumValueDeclaration) {
} else if (property instanceof EnumValue) {
return 'enum value';
} else {
throw new Error(`unknown property type "${property}"`);
Expand Down
8 changes: 4 additions & 4 deletions packages/concerto-analysis/src/comparers/properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* limitations under the License.
*/

import { EnumValueDeclaration, Field, ModelUtil } from '@accordproject/concerto-core';
import { EnumValue, Field, ModelUtil } from '@accordproject/concerto-core';
import * as semver from 'semver';
import { getDeclarationType, getPropertyType, getValidatorType } from '../compare-utils';
import { ComparerFactory } from '../comparer';
Expand All @@ -23,7 +23,7 @@ const propertyAdded: ComparerFactory = (context) => ({
return;
}
const classDeclarationType = getDeclarationType(b.getParent());
if (b instanceof EnumValueDeclaration) {
if (b instanceof EnumValue) {
context.report({
key: 'enum-value-added',
message: `The enum value "${b.getName()}" was added to the ${classDeclarationType} "${b.getParent().getName()}"`,
Expand Down Expand Up @@ -59,7 +59,7 @@ const propertyRemoved: ComparerFactory = (context) => ({
return;
}
const classDeclarationType = getDeclarationType(a.getParent());
if (a instanceof EnumValueDeclaration) {
if (a instanceof EnumValue) {
context.report({
key: 'enum-value-removed',
message: `The enum value "${a.getName()}" was removed from the ${classDeclarationType} "${a.getParent().getName()}"`,
Expand Down Expand Up @@ -104,7 +104,7 @@ const propertyTypeChanged: ComparerFactory = (context) => ({
element: a
});
return;
} else if (a instanceof EnumValueDeclaration || b instanceof EnumValueDeclaration) {
} else if (a instanceof EnumValue || b instanceof EnumValue) {
return;
}
const aIsArray = a.isArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ const scalarDeclarationExtendsChanged: ComparerFactory = (context) => ({
return;
}

if(a.getType() !== b.getType()) {
if(a.getScalarType() !== b.getScalarType()) {
context.report({
key: 'scalar-extends-changed',
message: `The scalar extends was changed from "${a.getType()}" to "${b.getType()}"`,
message: `The scalar extends was changed from "${a.getScalarType()}" to "${b.getScalarType()}"`,
element: b.getName()
});
}
Expand Down
5 changes: 4 additions & 1 deletion packages/concerto-analysis/test/unit/compare-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ import { getDeclarationType, getPropertyType, getValidatorType } from '../../src

const modelManager = new ModelManager();
const propertyAst = {
$class: '[email protected]',
name: 'myProp',
type: 'Boolean'
};
const modelAst = {
$class: '[email protected]',
name: 'Unknown',
namespace: '[email protected]',
properties: []
};
Expand All @@ -19,7 +22,7 @@ const field = new Field(classDeclaration, propertyAst);
const validator = new Validator(field, {});

test('should throw for unknown class declaration type', () => {
expect(() => getDeclarationType(classDeclaration)).toThrow('unknown class declaration type "ClassDeclaration {[email protected].undefined super=Concept enum=false abstract=false}"');
expect(() => getDeclarationType(classDeclaration)).toThrow('unknown class declaration type "ClassDeclaration {[email protected].Unknown super=Concept declarationKind=UnknownDeclaration abstract=false idField=null}"');
});

test('should throw for unknown thing', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/concerto-util/src/typedstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class TypedStack {
}

this.stack.push(obj);
//console.log('Push depth is: ' + this.stack.length + ', contents: ' + this.stack.toString() );
// console.log('Push depth is: ' + this.stack.length + ', contents: ' + this.stack.toString() );
}

/**
Expand All @@ -63,7 +63,7 @@ class TypedStack {
*/
peek(expectedType) {

//console.log( 'pop ' );
// console.log( 'pop ' );

if(this.stack.length < 1) {
throw new Error('Stack is empty!');
Expand Down

0 comments on commit d929ed8

Please sign in to comment.