UNPKG

stylesheet-loader

Version:
63 lines 3.96 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var normalizeColor_1 = require("../normalizeColor"); describe('normalizeColor', function () { it('should accept only spec compliant colors', function () { expect(normalizeColor_1.default('#abc')).not.toBe(null); expect(normalizeColor_1.default('#abcd')).not.toBe(null); expect(normalizeColor_1.default('#abcdef')).not.toBe(null); expect(normalizeColor_1.default('#abcdef01')).not.toBe(null); expect(normalizeColor_1.default('rgb(1,2,3)')).not.toBe(null); expect(normalizeColor_1.default('rgb(1, 2, 3)')).not.toBe(null); expect(normalizeColor_1.default('rgb( 1 , 2 , 3 )')).not.toBe(null); expect(normalizeColor_1.default('rgba(0, 0, 0, 1)')).not.toBe(null); }); it('should temporarly accept floating point values for rgb', function () { expect(normalizeColor_1.default('rgb(1.1, 2.1, 3.1)')).toBe('rgb(1,2,3)'); expect(normalizeColor_1.default('rgba(1.1, 2.1, 3.1, 1.0)')).toBe('rgb(1,2,3)'); }); it('should handle hex6 properly', function () { expect(normalizeColor_1.default('#000000')).toBe('rgb(0,0,0)'); expect(normalizeColor_1.default('#ffffff')).toBe('rgb(255,255,255)'); expect(normalizeColor_1.default('#ff00ff')).toBe('rgb(255,0,255)'); expect(normalizeColor_1.default('#abcdef')).toBe('rgb(171,205,239)'); expect(normalizeColor_1.default('#012345')).toBe('rgb(1,35,69)'); }); it('should handle hex3 properly', function () { expect(normalizeColor_1.default('#000')).toBe('rgb(0,0,0)'); expect(normalizeColor_1.default('#fff')).toBe('rgb(255,255,255)'); expect(normalizeColor_1.default('#f0f')).toBe('rgb(255,0,255)'); }); it('should handle hex8 properly', function () { expect(normalizeColor_1.default('#00000000')).toBe('rgba(0,0,0,0)'); expect(normalizeColor_1.default('#ffffffff')).toBe('rgb(255,255,255)'); expect(normalizeColor_1.default('#ffff00ff')).toBe('rgb(255,255,0)'); expect(normalizeColor_1.default('#abcdef01')).toBe('rgba(171,205,239,0.00392156862745098)'); expect(normalizeColor_1.default('#01234567')).toBe('rgba(1,35,69,0.403921568627451)'); }); it('should handle rgb properly', function () { expect(normalizeColor_1.default('rgb(0, 0, 0)')).toBe('rgb(0,0,0)'); expect(normalizeColor_1.default('rgb(0, 0, 255)')).toBe('rgb(0,0,255)'); expect(normalizeColor_1.default('rgb(100, 15, 69)')).toBe('rgb(100,15,69)'); expect(normalizeColor_1.default('rgb(255, 255, 255)')).toBe('rgb(255,255,255)'); }); it('should handle rgba properly', function () { expect(normalizeColor_1.default('rgba(0, 0, 0, 0.0)')).toBe('rgba(0,0,0,0)'); expect(normalizeColor_1.default('rgba(0, 0, 0, 0)')).toBe('rgba(0,0,0,0)'); expect(normalizeColor_1.default('rgba(0, 0, 0, 1.0)')).toBe('rgb(0,0,0)'); expect(normalizeColor_1.default('rgba(0, 0, 0, 1)')).toBe('rgb(0,0,0)'); expect(normalizeColor_1.default('rgba(100, 15, 69, 0.5)')).toBe('rgba(100,15,69,0.5)'); }); it('should handle hsl properly', function () { expect(normalizeColor_1.default('hsl(0, 0%, 0%)')).toBe('rgb(0,0,0)'); expect(normalizeColor_1.default('hsl(360, 100%, 100%)')).toBe('rgb(255,255,255)'); expect(normalizeColor_1.default('hsl(180, 50%, 50%)')).toBe('rgb(64,191,191)'); expect(normalizeColor_1.default('hsl(70, 25%, 75%)')).toBe('rgb(202,207,175)'); expect(normalizeColor_1.default('hsl(70, 100%, 75%)')).toBe('rgb(234,255,128)'); expect(normalizeColor_1.default('hsl(70, 0%, 75%)')).toBe('rgb(191,191,191)'); }); it('should return current string when not legal color', function () { expect(normalizeColor_1.default('var(--main-color)')).toBe('var(--main-color)'); }); }); //# sourceMappingURL=normalizeColor.js.map