Skip to content

Commit

Permalink
Added tests for form validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jpdjere authored May 3, 2024
1 parent 0b71b77 commit 07d81e6
Showing 1 changed file with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,32 @@ describe('helpers', () => {
expect(result).toEqual(expected);
});


// Users are allowed to input 0 in the form, but value is validated in the API layer
test('returns formatted object with max_signals set to 0', () => {
const mockDataWithZeroMaxSignals: AboutStepRule = {
...mockData,
maxSignals: 0,
};

const result = formatAboutStepData(mockDataWithZeroMaxSignals);

expect(result.max_signals).toEqual(0);
});

// Strings or empty values are replaced with undefined and overriden with the default value of 1000
test('returns formatted object with undefined max_signals for non-integer values inputs', () => {
const mockDataWithNonIntegerMaxSignals: AboutStepRule = {
...mockData,
// @ts-expect-error
maxSignals: '',
};

const result = formatAboutStepData(mockDataWithNonIntegerMaxSignals);

expect(result.max_signals).toEqual(undefined);
});

test('returns formatted object with endpoint exceptions_list', () => {
const result = formatAboutStepData(
{
Expand Down

0 comments on commit 07d81e6

Please sign in to comment.