fix: align v0.9 slider schema with spec#1487
Conversation
There was a problem hiding this comment.
Code Review
This pull request removes the step property from the SliderApi schema and the corresponding Angular SliderComponent. A regression test was added to verify that the schema now rejects the step property. Feedback suggests improving the robustness of this test by ensuring it specifically fails due to the unrecognized step key rather than other potential validation errors, and provided a code suggestion to implement this check.
| it('should reject non-spec step property', () => { | ||
| const slider = { | ||
| max: 100, | ||
| step: 5, | ||
| value: {literalNumber: 50}, | ||
| }; | ||
|
|
||
| assert.throws(() => SliderApi.schema.parse(slider)); | ||
| }); |
There was a problem hiding this comment.
The regression test for SliderApi should be more robust. Currently, assert.throws will pass if the schema parsing fails for any reason (e.g., an invalid value format or missing required fields). To ensure it specifically catches the rejection of the step property, it is better to first validate a correct object and then verify that adding step causes a specific error. Additionally, using a literal number for value is more consistent with other tests in this file.
it('should reject non-spec step property', () => {
const validSlider = {
max: 100,
value: 50,
};
// Verify it parses correctly without the 'step' property
SliderApi.schema.parse(validSlider);
const invalidSlider = {
...validSlider,
step: 5,
};
assert.throws(
() => SliderApi.schema.parse(invalidSlider),
/unrecognized_keys.*step/i
);
});|
Tightened the regression in 192683b so it first verifies the slider parses without |
Closes #1384.
Summary
stepproperty from the v0.9 WebCoreSliderApischemaSlider.stepis rejected instead of diverging from the frozen JSON catalogVerification
npm test -- --watch=falsefromrenderers/web_corenpx ng build libfromrenderers/angular