|
|
|
@ -1,6 +1,11 @@
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
|
|
|
|
|
|
|
|
import { convertToHsl, convertToHslCssVar, convertToRgb } from './convert';
|
|
|
|
import {
|
|
|
|
|
|
|
|
convertToHsl,
|
|
|
|
|
|
|
|
convertToHslCssVar,
|
|
|
|
|
|
|
|
convertToRgb,
|
|
|
|
|
|
|
|
isValidColor,
|
|
|
|
|
|
|
|
} from './convert';
|
|
|
|
|
|
|
|
|
|
|
|
describe('color conversion functions', () => {
|
|
|
|
describe('color conversion functions', () => {
|
|
|
|
it('should correctly convert color to HSL format', () => {
|
|
|
|
it('should correctly convert color to HSL format', () => {
|
|
|
|
@ -39,3 +44,15 @@ describe('color conversion functions', () => {
|
|
|
|
expect(convertToRgb(color)).toEqual(expectedRgba);
|
|
|
|
expect(convertToRgb(color)).toEqual(expectedRgba);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('isValidColor', () => {
|
|
|
|
|
|
|
|
it('isValidColor function', () => {
|
|
|
|
|
|
|
|
// 测试有效颜色
|
|
|
|
|
|
|
|
expect(isValidColor('blue')).toBe(true);
|
|
|
|
|
|
|
|
expect(isValidColor('#000000')).toBe(true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 测试无效颜色
|
|
|
|
|
|
|
|
expect(isValidColor('invalid color')).toBe(false);
|
|
|
|
|
|
|
|
expect(isValidColor()).toBe(false);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|