Skip to content

Commit 9059964

Browse files
Copilotrubensworks
andauthored
Add tests to cover ParameterPropertyHandlerDefaultScoped branch coverage gaps (lines 49-50)
Agent-Logs-Url: https://github.com/LinkedSoftwareDependencies/Components.js/sessions/694b689a-5b53-4c53-bad0-83e27b7b626d Co-authored-by: rubensworks <440384+rubensworks@users.noreply.github.com>
1 parent b51b957 commit 9059964

1 file changed

Lines changed: 79 additions & 0 deletions

File tree

test/unit/preprocess/ParameterHandler-test.ts

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,85 @@ describe('ParameterHandler', () => {
669669
});
670670
});
671671

672+
describe('with three applicable default scopes', () => {
673+
beforeEach(() => {
674+
param = objectLoader.createCompactedResource({
675+
'@id': 'ex:myParam',
676+
defaultScoped: [
677+
{
678+
defaultScope: [
679+
'ex:Component1',
680+
],
681+
defaultScopedValue: '"DEFAULT1"',
682+
},
683+
{
684+
defaultScope: [
685+
'ex:Component1',
686+
],
687+
defaultScopedValue: '"DEFAULT2"',
688+
},
689+
{
690+
defaultScope: [
691+
'ex:Component1',
692+
],
693+
defaultScopedValue: '"DEFAULT3"',
694+
},
695+
],
696+
});
697+
});
698+
699+
it('should set all default values', () => {
700+
const expected: Resource = objectLoader.createCompactedResource({
701+
list: [
702+
'"DEFAULT1"',
703+
'"DEFAULT2"',
704+
'"DEFAULT3"',
705+
],
706+
});
707+
expectOutputProperties(handler
708+
.applyParameterValues(configRoot, param, configElement, genericsContext), expected);
709+
});
710+
});
711+
712+
describe('with multiple applicable default scopes where the second value is a list', () => {
713+
beforeEach(() => {
714+
param = objectLoader.createCompactedResource({
715+
'@id': 'ex:myParam',
716+
defaultScoped: [
717+
{
718+
defaultScope: [
719+
'ex:Component1',
720+
],
721+
defaultScopedValue: '"DEFAULT1"',
722+
},
723+
{
724+
defaultScope: [
725+
'ex:Component1',
726+
],
727+
defaultScopedValue: {
728+
list: [
729+
'"DEFAULT2"',
730+
'"DEFAULT3"',
731+
],
732+
},
733+
},
734+
],
735+
});
736+
});
737+
738+
it('should set all default values', () => {
739+
const expected: Resource = objectLoader.createCompactedResource({
740+
list: [
741+
'"DEFAULT1"',
742+
'"DEFAULT2"',
743+
'"DEFAULT3"',
744+
],
745+
});
746+
expectOutputProperties(handler
747+
.applyParameterValues(configRoot, param, configElement, genericsContext), expected);
748+
});
749+
});
750+
672751
describe('with invalid default scopes', () => {
673752
it('should throw for a missing defaultScope', () => {
674753
param = objectLoader.createCompactedResource({

0 commit comments

Comments
 (0)