Skip to content

Commit

Permalink
feat(vocabulary): old breaking test fixed (#667)
Browse files Browse the repository at this point in the history
* feat(vocabulary): resolved bug for properties and added more test cases

Signed-off-by: sanketshevkar <[email protected]>

* feat(vocabulary): fix to support vocab attributes without '.'

Signed-off-by: sanketshevkar <[email protected]>

* feat(vocabulary): old breaking test fixed

Signed-off-by: sanketshevkar <[email protected]>

---------

Signed-off-by: sanketshevkar <[email protected]>
  • Loading branch information
sanketshevkar committed Jul 12, 2023
1 parent 58fdcbf commit 9923a25
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions packages/concerto-vocabulary/lib/vocabulary.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ class Vocabulary {
return null;
}
if(!propertyName) {
return identifier ? decl[`.${identifier}`] : decl[declarationName];
return identifier ? decl[identifier] : decl[declarationName];
}
else {
const property = decl.properties ? decl.properties.find(d => d[propertyName]) : null;
return property ? identifier ? property[`.${identifier}`] : property[propertyName] : null;
return property ? identifier ? property[identifier] : property[propertyName] : null;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Object {
"value": "VIN",
},
],
"name": "Term_.tooltip",
"name": "Term_tooltip",
},
"target": Object {
"$class": "org.accordproject.decoratorcommands.CommandTarget",
Expand Down Expand Up @@ -211,7 +211,7 @@ Object {
"value": "A heavy goods vehicle",
},
],
"name": "Term_.description",
"name": "Term_description",
},
"target": Object {
"$class": "org.accordproject.decoratorcommands.CommandTarget",
Expand Down Expand Up @@ -250,7 +250,7 @@ Object {
"value": "The weight of the truck in KG",
},
],
"name": "Term_.description",
"name": "Term_description",
},
"target": Object {
"$class": "org.accordproject.decoratorcommands.CommandTarget",
Expand All @@ -270,7 +270,7 @@ Object {
"value": "Truck weight",
},
],
"name": "Term_.tooltip",
"name": "Term_tooltip",
},
"target": Object {
"$class": "org.accordproject.decoratorcommands.CommandTarget",
Expand Down Expand Up @@ -310,7 +310,7 @@ Object {
"value": "VIN",
},
],
"name": "Term_.tooltip",
"name": "Term_tooltip",
},
"target": Object {
"$class": "org.accordproject.decoratorcommands.CommandTarget",
Expand Down
2 changes: 1 addition & 1 deletion packages/concerto-vocabulary/test/org.acme_en-gb.voc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ locale: en-gb
namespace: org.acme
declarations:
- Truck: A lorry
.description: A heavy goods vehicle
description: A heavy goods vehicle
- Color: A colour
- Milkfloat
14 changes: 7 additions & 7 deletions packages/concerto-vocabulary/test/org.acme_en.voc
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ declarations:
- Vehicle: A road vehicle
properties:
- vin: Vehicle Identification Number
.tooltip: VIN
tooltip: VIN
- model: Model of the vehicle
- Truck: A truck
.description: A vehicle capable of carrying cargo
.tooltip: Truck
description: A vehicle capable of carrying cargo
tooltip: Truck
properties:
- weight: The weight of the truck
.description: The weight of the truck in KG
.tooltip: Truck weight
description: The weight of the truck in KG
tooltip: Truck weight
- horsePower: The horse power of the truck
.description: The horse power of the truck
.tooltip: Truck HP
description: The horse power of the truck
tooltip: Truck HP
12 changes: 6 additions & 6 deletions packages/concerto-vocabulary/test/vocabularymanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,15 @@ describe('VocabularyManager', () => {
it('getTerms - lookup declaration', () => {
const terms = vocabularyManager.getTerms('org.acme', 'en', 'Truck');
terms.Truck.should.equal('A truck');
terms['.description'].should.equal('A vehicle capable of carrying cargo');
terms['.tooltip'].should.equal('Truck');
terms.description.should.equal('A vehicle capable of carrying cargo');
terms.tooltip.should.equal('Truck');
});

it('getTerms - lookup property', () => {
const terms = vocabularyManager.getTerms('org.acme', 'en', 'Truck', 'weight');
terms.weight.should.equal('The weight of the truck');
terms['.description'].should.equal('The weight of the truck in KG');
terms['.tooltip'].should.equal('Truck weight');
terms.description.should.equal('The weight of the truck in KG');
terms.tooltip.should.equal('Truck weight');
});

it('getTerms - lookup unicode', () => {
Expand Down Expand Up @@ -274,7 +274,7 @@ describe('VocabularyManager', () => {

it('resolveTerms - class with identifier', () => {
const terms = vocabularyManager.resolveTerms(modelManager, 'org.acme', 'en-gb', 'Truck');
terms['.description'].should.equal('A heavy goods vehicle');
terms.description.should.equal('A heavy goods vehicle');
});

it('resolveTerms - property', () => {
Expand All @@ -284,7 +284,7 @@ describe('VocabularyManager', () => {

it('resolveTerms - property with identifier', () => {
const terms = vocabularyManager.resolveTerms(modelManager, 'org.acme', 'en-gb', 'Truck', 'weight', 'description');
terms['.description'].should.equal('The weight of the truck in KG');
terms.description.should.equal('The weight of the truck in KG');
});

it('resolveTerms - property on super type', () => {
Expand Down

0 comments on commit 9923a25

Please sign in to comment.