-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fill missing varTypes in parameter values when receiving scenarios
Note that this commit changes the order of calls when opening a workspace: the solution is now fetched before fetching the scenarios
- Loading branch information
Showing
5 changed files
with
89 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright (c) Cosmo Tech. | ||
// Licensed under the MIT license. | ||
import { ScenariosUtils } from '../ScenariosUtils'; | ||
|
||
describe('patchScenarioParameterValues', () => { | ||
test.each` | ||
solutionParameters | parameterValues | ||
${undefined} | ${undefined} | ||
${undefined} | ${null} | ||
${undefined} | ${[]} | ||
${undefined} | ${0} | ||
${undefined} | ${false} | ||
${undefined} | ${''} | ||
${undefined} | ${'foo'} | ||
${null} | ${undefined} | ||
${null} | ${null} | ||
${null} | ${[]} | ||
${null} | ${0} | ||
${null} | ${false} | ||
${null} | ${''} | ||
${null} | ${'foo'} | ||
${[]} | ${undefined} | ||
${[]} | ${null} | ||
${[]} | ${[]} | ||
${[]} | ${0} | ||
${[]} | ${false} | ||
${[]} | ${''} | ||
${[]} | ${'foo'} | ||
`( | ||
'should do nothing without error when arguments are nullish or not arrays', | ||
({ solutionParameters, parameterValues }) => { | ||
expect(() => ScenariosUtils.patchScenarioParameterValues(solutionParameters, parameterValues)).not.toThrow(); | ||
} | ||
); | ||
|
||
test('should fill missing varTypes based on solution description', () => { | ||
const spyConsoleWarn = jest.spyOn(console, 'warn').mockImplementation(() => {}); | ||
|
||
const solutionParameters = [ | ||
{ id: 'p0', varType: 'bool' }, | ||
{ id: 'p1', varType: 'date' }, | ||
{ id: 'p3', varType: 'string' }, | ||
]; | ||
const parameterValues = [ | ||
{ parameterId: 'p0', value: 'p0' }, | ||
{ parameterId: 'p1', varType: null, value: 'p1' }, | ||
{ parameterId: 'p2', varType: null, value: 'p2' }, | ||
{ parameterId: 'p3', varType: 'string', value: 'p3' }, | ||
]; | ||
const expectedParameterValues = [ | ||
{ parameterId: 'p0', varType: 'bool', value: 'p0' }, | ||
{ parameterId: 'p1', varType: 'date', value: 'p1' }, | ||
{ parameterId: 'p2', varType: null, value: 'p2' }, // Not defined in solution | ||
{ parameterId: 'p3', varType: 'string', value: 'p3' }, | ||
]; | ||
|
||
ScenariosUtils.patchScenarioParameterValues(solutionParameters, parameterValues); | ||
expect(parameterValues).toStrictEqual(expectedParameterValues); | ||
expect(spyConsoleWarn).toHaveBeenCalledTimes(1); | ||
|
||
spyConsoleWarn.mockClear(); | ||
}); | ||
}); |