Files
privacy.sexy/tests/unit/application/Parser/Executable/Script/Compiler/ParameterNameValidator.spec.ts
undergroundwires fac26a6ca0 Add type validation for parameters and fix types
This commit introduces type validation for parameter values within the
parser/compiler, aligning with the YAML schema. It aims to eliminate
dependencies on side effects in the collection files.

This update changes the treatment of data types in the Windows
collection, moving away from unintended type casting by the compiler.
Previously, numeric and boolean values were used even though only
string types were supported. This behavior was unstable and untested,
and has now been adjusted to use strings exclusively.

Changes ensure that parameter values are correctly validated
as strings, enhancing stability and maintainability.
2024-06-19 17:01:27 +02:00

25 lines
956 B
TypeScript

import { describe, it } from 'vitest';
import { TypeValidatorStub } from '@tests/unit/shared/Stubs/TypeValidatorStub';
import { validateParameterName } from '@/application/Parser/Executable/Script/Compiler/Function/Shared/ParameterNameValidator';
import type { NonEmptyStringAssertion } from '@/application/Parser/Common/TypeValidator';
describe('ParameterNameValidator', () => {
it('asserts correctly', () => {
// arrange
const parameterName = 'expected-parameter-name';
const validator = new TypeValidatorStub();
const expectedAssertion: NonEmptyStringAssertion = {
value: parameterName,
valueName: 'parameter name',
rule: {
expectedMatch: /^[0-9a-zA-Z]+$/,
errorMessage: `parameter name must be alphanumeric but it was "${parameterName}".`,
},
};
// act
validateParameterName(parameterName, validator);
// assert
validator.assertNonEmptyString(expectedAssertion);
});
});