Skip to content

Commit

Permalink
fix(abap-deploy-config-inquirer ): add more robust test
Browse files Browse the repository at this point in the history
  • Loading branch information
longieirl committed Oct 7, 2024
1 parent 54a7caa commit 461741d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,8 @@ function getScpPrompt(backendTarget?: BackendTarget): Question<AbapDeployConfigA
const scpChoice = answers[abapDeployConfigInternalPromptNames.scp];
const targetChoice = answers[abapDeployConfigInternalPromptNames.targetSystem];
// scpChoice by default is true so only update state if target system is a URL
if (scpChoice == true && targetChoice === TargetSystemType.Url) {
PromptState.abapDeployConfig.scp = true;
} else if (targetChoice === TargetSystemType.Url) {
// Needs to be reset when user is toggling between scp and non-scp
PromptState.abapDeployConfig.scp = false;
}
PromptState.abapDeployConfig.scp =
scpChoice === true && targetChoice === TargetSystemType.Url ? true : false;
return false;
},
name: abapDeployConfigInternalPromptNames.scpSetter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ describe('getAbapTargetPrompts', () => {
scp: true
})
).toBe(false);
expect(PromptState.abapDeployConfig.scp).toBe(true);
// Lets toggle the question
expect(
(scpSetterPrompt.when as Function)({
Expand All @@ -347,6 +348,14 @@ describe('getAbapTargetPrompts', () => {
})
).toBe(false);
expect(PromptState.abapDeployConfig.scp).toBe(false);
// When SCP is not answered
expect(
(scpSetterPrompt.when as Function)({
targetSystem: TargetSystemType.Url,
url: 'https://mock.target1.url.com'
})
).toBe(false);
expect(PromptState.abapDeployConfig.scp).toBe(false);
} else {
throw new Error('Scp setter prompt not found');
}
Expand Down
33 changes: 1 addition & 32 deletions pnpm-lock.yaml

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

0 comments on commit 461741d

Please sign in to comment.