Skip to content

Commit efacf8f

Browse files
fix: update HSL parsing test to enforce percentage unit validation
Replaced the test for parsing HSL colors without units for saturation and lightness with one that ensures an error is thrown for missing percentage units, aligning with stricter validation requirements. Signed-off-by: Mallik Cheripally <mallikcheripally@gmail.com>
1 parent 924adf3 commit efacf8f

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

tests/parser/parseHsl.test.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,10 @@ describe('parseHsl', () => {
8686
});
8787
});
8888

89-
test('parses HSL color with no units for saturation and lightness', () => {
90-
const result = parseHsl('hsl(180, 100, 50)');
91-
expect(result).toEqual({
92-
h: 180,
93-
hUnit: undefined,
94-
hDeg: 180,
95-
s: 100,
96-
sUnit: undefined,
97-
l: 50,
98-
lUnit: undefined
99-
});
89+
test('throws for HSL color without percentage units on saturation or lightness', () => {
90+
expect(() => parseHsl('hsl(180, 100, 50)')).toThrow('Invalid HSL color format');
91+
expect(() => parseHsl('hsl(180, 100%, 50)')).toThrow('Invalid HSL color format');
92+
expect(() => parseHsl('hsl(180, 100, 50%)')).toThrow('Invalid HSL color format');
10093
});
10194
});
10295

103-

0 commit comments

Comments
 (0)