|
@@ -1,6 +1,6 @@
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
|
|
-import { convertToHsl, convertToHslCssVar, isValidColor } from './convert';
|
|
|
+import { convertToHsl, convertToHslCssVar, convertToRgb } from './convert';
|
|
|
|
|
|
describe('color conversion functions', () => {
|
|
|
it('should correctly convert color to HSL format', () => {
|
|
@@ -26,16 +26,16 @@ describe('color conversion functions', () => {
|
|
|
const expectedHsl = '0 100% 50% / 0.5';
|
|
|
expect(convertToHslCssVar(color)).toEqual(expectedHsl);
|
|
|
});
|
|
|
-});
|
|
|
|
|
|
-describe('isValidColor', () => {
|
|
|
- it('isValidColor function', () => {
|
|
|
-
|
|
|
- expect(isValidColor('blue')).toBe(true);
|
|
|
- expect(isValidColor('#000000')).toBe(true);
|
|
|
+ it('should correctly convert color to RGB CSS variable format', () => {
|
|
|
+ const color = 'hsl(284, 100%, 50%)';
|
|
|
+ const expectedRgb = 'rgb(187,0,255)';
|
|
|
+ expect(convertToRgb(color)).toEqual(expectedRgb);
|
|
|
+ });
|
|
|
|
|
|
-
|
|
|
- expect(isValidColor('invalid color')).toBe(false);
|
|
|
- expect(isValidColor()).toBe(false);
|
|
|
+ it('should correctly convert color with alpha to RGBA CSS variable format', () => {
|
|
|
+ const color = 'hsla(284, 100%, 50%, 0.92)';
|
|
|
+ const expectedRgba = 'rgba(187,0,255,0.92)';
|
|
|
+ expect(convertToRgb(color)).toEqual(expectedRgba);
|
|
|
});
|
|
|
});
|