config redirect

This commit is contained in:
Nuno Coração
2023-01-29 22:30:24 +00:00
parent 17557c7d73
commit 5fb4bd8083
9905 changed files with 1258996 additions and 36355 deletions

66
node_modules/khroma/test/color/hex.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
/* IMPORT */
import {describe} from 'fava';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'Hex', it => {
it ( 'parses hex colors', t => {
const tests = [
/* RGB */
['#000', '#000000'],
['#fff', '#ffffff'],
['#a2b', '#aa22bb'],
['#a2B', '#aa22bb'],
/* RGBA */
['#0000', '#00000000'],
['#fffF', '#ffffff'],
['#fff8', '#ffffff88'],
['#a2bf', '#aa22bb'],
['#a2Bf', '#aa22bb'],
/* RRGGBB */
['#000000', '#000000'],
['#FFFFFF', '#ffffff'],
['#ffffff', '#ffffff'],
['#ae12b4', '#ae12b4'],
['#Ae12B4', '#ae12b4'],
/* RRGGBBAA */
['#000000ff', '#000000'],
['#00000000', '#00000000'],
['#ffffffa8', '#ffffffa8'],
['#ffffffA8', '#ffffffa8']
];
tests.forEach ( ([ input, output ]) => {
t.is ( Color.format.hex.stringify ( Color.parse ( input ) ), output );
});
});
it ( 'throws with unsupported colors', t => {
const colors = [
'#',
'#0',
'#00',
'#ggg',
'#zzz',
'fff',
'#0 0 0',
'# 000',
'#aabbc',
'#aabbccd',
'#aabbccdde'
];
colors.forEach ( color => {
t.throws ( () => Color.parse ( color ), /unsupported/i );
});
});
});

106
node_modules/khroma/test/color/hsl.js generated vendored Normal file
View File

@@ -0,0 +1,106 @@
/* IMPORT */
import {describe} from 'fava';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'HSL', it => {
it ( 'parses HSL colors', t => {
const tests = [
/* NO UNIT HUE */
['hsl(0, 0%, 0%)', 'hsl(0, 0%, 0%)'],
['hsl(0, 100%, 0%)', 'hsl(0, 100%, 0%)'],
['hsl(0, 0%, 100%)', 'hsl(0, 0%, 100%)'],
['hsl(0, 100%, 100%)', 'hsl(0, 100%, 100%)'],
['hsl(180, 50%, 50%)', 'hsl(180, 50%, 50%)'],
['hsl(180, 40.4%, 70.4%)', 'hsl(180, 40.4%, 70.4%)'],
/* S & L CLAMPING - H WRAPPING */
['hsl(-180, 40.4%, 70.4%)', 'hsl(-180, 40.4%, 70.4%)'],
['hsl(180, -40.4%, -70.4%)', 'hsl(180, 0%, 0%)'],
['hsl(180, 400.4%, 700.4%)', 'hsl(180, 100%, 100%)'],
['hsl(540, 100%, 50%)', 'hsl(180, 100%, 50%)'],
/* DEGREES */
['hsl(-180deg, 50%, 50%)', 'hsl(-180, 50%, 50%)'],
['hsl(0deg, 50%, 50%)', 'hsl(0, 50%, 50%)'],
['hsl(180deg, 50%, 50%)', 'hsl(180, 50%, 50%)'],
['hsl(360deg, 50%, 50%)', 'hsl(0, 50%, 50%)'],
['hsl(540deg, 50%, 50%)', 'hsl(180, 50%, 50%)'],
/* GRADIANS */
['hsl(0grad, 50%, 50%)', 'hsl(0, 50%, 50%)'],
['hsl(200grad, 50%, 50%)', 'hsl(180, 50%, 50%)'],
['hsl(400grad, 50%, 50%)', 'hsl(0, 50%, 50%)'],
/* RADIANS */
['hsl(0rad, 50%, 50%)', 'hsl(0, 50%, 50%)'],
['hsl(3.14159265359rad, 50%, 50%)', 'hsl(180, 50%, 50%)'],
/* TURNS */
['hsl(0turn, 50%, 50%)', 'hsl(0, 50%, 50%)'],
['hsl(0.5turn, 50%, 50%)', 'hsl(180, 50%, 50%)'],
['hsl(1turn, 50%, 50%)', 'hsl(0, 50%, 50%)'],
/* SCIENTIFIC NOTATION */
['hsl(1.8e2, 4.04e1%, .704e2%)', 'hsl(180, 40.4%, 70.4%)'],
['hsl(1.8e2deg, 4.04e1%, .704e2%)', 'hsl(180, 40.4%, 70.4%)'],
['hsl(1800e-1deg, 404e-1%, 7040e-2%)', 'hsl(180, 40.4%, 70.4%)'],
/* WITH COMMAS AND WEIRD SPACES */
['hsl( 0 , 0% , 0% )', 'hsl(0, 0%, 0%)'],
['hsl(0,0%,0%)', 'hsl(0, 0%, 0%)'],
/* WITHOUT COMMAS */
['hsl(0 0% 0%)', 'hsl(0, 0%, 0%)'],
['hsl( 0 0% 0% )', 'hsl(0, 0%, 0%)'],
['hsl(180deg 50% 50%)', 'hsl(180, 50%, 50%)'],
['hsl(180 40.4% 70.4%)', 'hsl(180, 40.4%, 70.4%)'],
/* WEIRD CASING */
['HSL(0 0% 0%)', 'hsl(0, 0%, 0%)'],
['hSl(0 0% 0%)', 'hsl(0, 0%, 0%)']
];
tests.forEach ( ([ input, output ]) => {
t.is ( Color.format.hsl.stringify ( Color.parse ( input ) ), output );
});
});
it ( 'throws with unsupported colors', t => {
const colors = [
'hsl',
'hsl()',
'hsl(0, 0)',
'hsl(0, 1, dog)',
'hsl(0de, 0, 0)',
'hsl(0gra, 0, 0)',
'hsl(1, 2, 3, 4, 5)',
'hsl(1/2/3)',
'hsl(1,, 20, 255)',
'hsl(1%,, 20%, 255%)',
'hsl(1%, 255%)',
'hsl(1%, 10%%, 255%)',
'hsl(1%, %10%, 255%)',
'hsl(1)',
'hsl(1, 20, 255',
'hsl 1, 20, 255',
'hsl 1, 20, 255)',
'hsl(1, a, 255)',
'hsl (1, 2, 255)',
'hsl(1,2,3..5)',
'hsl(1, 2, 3.4.5)',
'hslQ(1, 2, 255)',
'h s l(1, 2, 255)',
'hsl(0, 0, 0)',
'hsl(0, 100, 0)',
'hsl(0, 0, 100)',
'hsl(0, 100, 100)',
'hsl(180, 50, 50)',
'hsl(180, 40.4, 70.4)'
];
colors.forEach ( color => {
t.throws ( () => Color.parse ( color ), /unsupported/i );
});
});
});

85
node_modules/khroma/test/color/hsla.js generated vendored Normal file
View File

@@ -0,0 +1,85 @@
/* IMPORT */
import {describe} from 'fava';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'HSLA', it => {
it ( 'parses HSLA colors', t => {
const tests = [
/* NO UNIT HUE */
['hsla(0, 0%, 0%, 0)', 'hsla(0, 0%, 0%, 0)'],
['hsla(0, 0%, 0%)', 'hsl(0, 0%, 0%)'],
['hsla(0, 0%, 0%, 10)', 'hsl(0, 0%, 0%)'],
['hsla(0, 0%, 0%, -10)', 'hsla(0, 0%, 0%, 0)'],
['hsla(0, 0%, 0%, 0.5)', 'hsla(0, 0%, 0%, 0.5)'],
['hsla(0, 0%, 0%, .5)', 'hsla(0, 0%, 0%, 0.5)'],
['hsla(0, 0%, 0%, 0.5 )', 'hsla(0, 0%, 0%, 0.5)'],
/* PERCENTAGE 0~100 */
['hsla(0, 0%, 0%, 0%)', 'hsla(0, 0%, 0%, 0)'],
['hsla(0, 0%, 0%, 100%)', 'hsl(0, 0%, 0%)'],
['hsla(0, 0%, 0%, 110%)', 'hsl(0, 0%, 0%)'],
['hsla(0, 0%, 0%, -110%)', 'hsla(0, 0%, 0%, 0)'],
['hsla(0, 0%, 0%, 50%)', 'hsla(0, 0%, 0%, 0.5)'],
['hsla(0, 0%, 0%, 50.5%)', 'hsla(0, 0%, 0%, 0.505)'],
/* WITH COMMAS AND WEIRD SPACES */
['hsla( 1 , 20% , 50%, 0.5 )', 'hsla(1, 20%, 50%, 0.5)'],
['hsla(1,20%,50%,50%)', 'hsla(1, 20%, 50%, 0.5)'],
['hsla( 1,20%,50%,0.5 )', 'hsla(1, 20%, 50%, 0.5)'],
/* WITH SLASH */
['hsla(0 0% 0% / 0.4)', 'hsla(0, 0%, 0%, 0.4)'],
['hsla(0 0% 0%/0.4)', 'hsla(0, 0%, 0%, 0.4)'],
['hsla(0 0% 0% / 40%)', 'hsla(0, 0%, 0%, 0.4)'],
['hsla(0, 0%, 0% / 40%)', 'hsla(0, 0%, 0%, 0.4)'],
['hsla(0,0%,0%/40%)', 'hsla(0, 0%, 0%, 0.4)'],
/* SCIENTIFIC NOTATION */
['hsla(1e2, 2e1%, .5e2%, +.25e2%)', 'hsla(100, 20%, 50%, 0.25)'],
['hsla(1e2, 2e1%, .5e2%, +.25e1%)', 'hsla(100, 20%, 50%, 0.025)'],
['hsla(1e2, 2e1%, .5e2%, +.25e0%)', 'hsla(100, 20%, 50%, 0.0025)'],
['hsla(1e2, 2e1%, .5e2%, .25e0)', 'hsla(100, 20%, 50%, 0.25)'],
['hsla(1e2, 2e1%, .5e2%, .25e1)', 'hsl(100, 20%, 50%)'],
['hsla(1e2, 2e1%, .5e2%, 25e-2)', 'hsla(100, 20%, 50%, 0.25)'],
/* MIXED UNITS */
['hsla(1, 20%, .5e2%, +.25e2%)', 'hsla(1, 20%, 50%, 0.25)'],
/* WEIRD CASING */
['HSLA(1, 20%, 50%, 0.5)', 'hsla(1, 20%, 50%, 0.5)'],
['hSlA(1, 20%, 50%, 0.5)', 'hsla(1, 20%, 50%, 0.5)']
];
tests.forEach ( ([ input, output ]) => {
t.is ( Color.format.hsla.stringify ( Color.parse ( input ) ), output );
});
});
it ( 'throws with unsupported colors', t => {
const colors = [
'hsla()',
'hsla(51 170 51 0.4)',
'hsla(1, 2, 3, 4, 5)',
'hsla(0, 0, 0, 0..5)',
'hsla(0, 0, 0, 0.5.)',
'hsla(0, 0, 0, 0%%)',
'hsla(51 170 51 // 0.4)',
'hsla(1ee2, .5e1, .5e0, +.25e2%)',
'hsla(1f2, .5e1, .5e0, +.25e2%)',
'hsla(0, 0, 0, 0)',
'hsla(0, 100, 0, 0)',
'hsla(0, 0, 100, 0)',
'hsla(0, 100, 100, 0)',
'hsla(180, 50, 50, 0)',
'hsla(180, 40.4, 70.4, 0)'
];
colors.forEach ( color => {
t.throws ( () => Color.parse ( color ), /unsupported/i );
});
});
});

38
node_modules/khroma/test/color/keyword.js generated vendored Normal file
View File

@@ -0,0 +1,38 @@
/* IMPORT */
import {describe} from 'fava';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'Keyword', it => {
it ( 'parses keywords colors', t => {
const tests = [
['black', '#000000'],
['BLACK', '#000000'],
['tranSpaRent', '#00000000']
];
tests.forEach ( ([ input, output ]) => {
t.is ( Color.format.hex.stringify ( Color.parse ( input ) ), output );
});
});
it ( 'throws with unsupported colors', t => {
const colors = [
'foo',
'bar'
];
colors.forEach ( color => {
t.throws ( () => Color.parse ( color ), /unsupported/i );
});
});
});

73
node_modules/khroma/test/color/rgb.js generated vendored Normal file
View File

@@ -0,0 +1,73 @@
/* IMPORT */
import {describe} from 'fava';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'RGB', it => {
it ( 'parses RGB colors', t => {
const tests = [
/* DECIAML 0~255 */
['rgb(1, 20, 255)', 'rgb(1, 20, 255)'],
['rgb(1.99, 20.5, 255)', 'rgb(1.99, 20.5, 255)'],
['rgb(300, 255, -100)', 'rgb(255, 255, 0)'],
/* PERCENTAGE 0~100 */
['rgb(10%, 20%, 30%)', 'rgb(25.5, 51, 76.5)'],
['rgb(10.5%, 20.7%, 30%)', 'rgb(26.775, 52.785, 76.5)'],
['rgb(100% 200% -30%)', 'rgb(255, 255, 0)'],
/* WITH COMMAS AND WEIRD SPACES */
['rgb( 1 , 20 , 255 )', 'rgb(1, 20, 255)'],
['rgb(1,20,255)', 'rgb(1, 20, 255)'],
['rgb( 1,20,255 )', 'rgb(1, 20, 255)'],
/* WITHOUT COMMAS */
['rgb(10% 20% 30%)', 'rgb(25.5, 51, 76.5)'],
['rgb(1 20 255)', 'rgb(1, 20, 255)'],
['rgb( 1 20 255 )', 'rgb(1, 20, 255)'],
/* MIXED UNITS */
['rgb(10% 20 30%)', 'rgb(25.5, 20, 76.5)'],
['rgb(1 25.5 25.5)', 'rgb(1, 25.5, 25.5)'],
/* WEIRD CASING */
['RGB(1, 20, 255)', 'rgb(1, 20, 255)'],
['rGb(1, 20, 255)', 'rgb(1, 20, 255)']
];
tests.forEach ( ([ input, output ]) => {
t.is ( Color.format.rgb.stringify ( Color.parse ( input ) ), output );
});
});
it ( 'throws with unsupported colors', t => {
const colors = [
'rgb()',
'rgb(1, 2, 3, 4, 5)',
'rgb(1/2/3)',
'rgb(1,, 20, 255)',
'rgb(1%,, 20%, 255%)',
'rgb(1%, 255%)',
'rgb(1%, 10%%, 255%)',
'rgb(1%, %10%, 255%)',
'rgb(1)',
'rgb(1, 20, 255',
'rgb 1, 20, 255',
'rgb 1, 20, 255)',
'rgb(1, a, 255)',
'rgb (1, 2, 255)',
'rgb(1,2,3..5)',
'rgb(1, 2, 3.4.5)',
'rgbQ(1, 2, 255)',
'r g b(1, 2, 255)'
];
colors.forEach ( color => {
t.throws ( () => Color.parse ( color ), /unsupported/i );
});
});
});

78
node_modules/khroma/test/color/rgba.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
/* IMPORT */
import {describe} from 'fava';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'RGBA', it => {
it ( 'parses RGBA colors', t => {
const tests = [
/* FRACTION 0~1 */
['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 0)'],
['rgba(0, 0, 0)', 'rgb(0, 0, 0)'],
['rgba(0, 0, 0, 10)', 'rgb(0, 0, 0)'],
['rgba(0, 0, 0, -10)', 'rgba(0, 0, 0, 0)'],
['rgba(0, 0, 0, 0.5)', 'rgba(0, 0, 0, 0.5)'],
['rgba(0, 0, 0, .5)', 'rgba(0, 0, 0, 0.5)'],
['rgba(0, 0, 0, 0.5 )', 'rgba(0, 0, 0, 0.5)'],
/* PERCENTAGE 0~100 */
['rgba(0, 0, 0, 0%)', 'rgba(0, 0, 0, 0)'],
['rgba(0, 0, 0, 100%)', 'rgb(0, 0, 0)'],
['rgba(0, 0, 0, 110%)', 'rgb(0, 0, 0)'],
['rgba(0, 0, 0, -110%)', 'rgba(0, 0, 0, 0)'],
['rgba(0, 0, 0, 50%)', 'rgba(0, 0, 0, 0.5)'],
['rgba(0, 0, 0, 50.5%)', 'rgba(0, 0, 0, 0.505)'],
/* WITH COMMAS AND WEIRD SPACES */
['rgba( 1 , 20 , 255, 0.5 )', 'rgba(1, 20, 255, 0.5)'],
['rgba(1,20,255,50%)', 'rgba(1, 20, 255, 0.5)'],
['rgba( 1,20,255,0.5 )', 'rgba(1, 20, 255, 0.5)'],
/* WITH SLASH */
['rgba(51 170 51 / 0.4)', 'rgba(51, 170, 51, 0.4)'],
['rgba(51 170 51/0.4)', 'rgba(51, 170, 51, 0.4)'],
['rgba(51 170 51 / 40%)', 'rgba(51, 170, 51, 0.4)'],
['rgba(51, 170, 51 / 40%)', 'rgba(51, 170, 51, 0.4)'],
['rgba(51,170,51/40%)', 'rgba(51, 170, 51, 0.4)'],
/* SCIENTIFIC NOTATION */
['rgba(1e2, .5e1, .5e0, +.25e2%)', 'rgba(100, 5, 0.5, 0.25)'],
['rgba(1e2, .5e1, .5e0, +.25e1%)', 'rgba(100, 5, 0.5, 0.025)'],
['rgba(1e2, .5e1, .5e0, +.25e0%)', 'rgba(100, 5, 0.5, 0.0025)'],
['rgba(1e2, .5e1, .5e0, .25e0)', 'rgba(100, 5, 0.5, 0.25)'],
['rgba(1e2, .5e1, .5e0, .25e1)', 'rgb(100, 5, 0.5)'],
/* MIXED UNITS */
['rgba(1, 10%, .5e0, +.25e2%)', 'rgba(1, 25.5, 0.5, 0.25)'],
/* WEIRD CASING */
['RGBA(1, 20, 255, 0.5)', 'rgba(1, 20, 255, 0.5)'],
['rgbA(1, 20, 255, 0.5)', 'rgba(1, 20, 255, 0.5)']
];
tests.forEach ( ([ input, output ]) => {
t.is ( Color.format.rgba.stringify ( Color.parse ( input ) ), output );
});
});
it ( 'throws with unsupported colors', t => {
const colors = [
'rgba()',
'rgba(51 170 51 0.4)',
'rgba(1, 2, 3, 4, 5)',
'rgba(0, 0, 0, 0..5)',
'rgba(0, 0, 0, 0.5.)',
'rgba(0, 0, 0, 0%%)',
'rgba(51 170 51 // 0.4)',
'rgba(1ee2, .5e1, .5e0, +.25e2%)',
'rgba(1f2, .5e1, .5e0, +.25e2%)'
];
colors.forEach ( color => {
t.throws ( () => Color.parse ( color ), /unsupported/i );
});
});
});

89
node_modules/khroma/test/methods/adjust.js generated vendored Normal file
View File

@@ -0,0 +1,89 @@
/* IMPORT */
import {describe} from 'fava';
import {adjust} from '../../dist/index.js';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'adjust', it => {
it ( 'increases or decreases the value of any RGB channel of the color', t => {
const tests = [
[['rgb(0, 0, 0)', { r: 100 }], 'rgb(100, 0, 0)'],
[['rgb(0, 0, 0)', { g: 100 }], 'rgb(0, 100, 0)'],
[['rgb(0, 0, 0)', { b: 100 }], 'rgb(0, 0, 100)'],
[['rgb(0, 0, 0)', { r: 100, g: 100 }], 'rgb(100, 100, 0)'],
[['rgb(0, 0, 0)', { r: 100, g: 100, b: 100 }], 'rgb(100, 100, 100)'],
[['rgb(255, 255, 255)', { r: -100 }], 'rgb(155, 255, 255)'],
[['rgb(255, 255, 255)', { g: -100 }], 'rgb(255, 155, 255)'],
[['rgb(255, 255, 255)', { b: -100 }], 'rgb(255, 255, 155)'],
[['rgb(200, 0, 0)', { r: 100 }], 'rgb(255, 0, 0)'],
[['rgb(100, 0, 0)', { r: -200 }], 'rgb(0, 0, 0)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( Color.format.rgb.stringify ( Color.parse ( adjust ( ...args ) ) ), output );
});
});
it ( 'increases or decreases the value of any HSL channel of the color', t => {
const tests = [
[['hsl(0, 50%, 50%)', { h: 100 }], 'hsl(100, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { s: 25 }], 'hsl(0, 75%, 50%)'],
[['hsl(0, 50%, 50%)', { l: 25 }], 'hsl(0, 50%, 75%)'],
[['hsl(0, 50%, 50%)', { h: 100, s: 25 }], 'hsl(100, 75%, 50%)'],
[['hsl(0, 50%, 50%)', { h: 100, s: 25, l: 25 }], 'hsl(100, 75%, 75%)'],
[['hsl(100, 50%, 50%)', { h: -100 }], 'hsl(0, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { s: -25 }], 'hsl(0, 25%, 50%)'],
[['hsl(0, 50%, 50%)', { l: -25 }], 'hsl(0, 50%, 25%)'],
[['hsl(300, 50%, 50%)', { h: 100 }], 'hsl(40, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { h: -100 }], 'hsl(-100, 50%, 50%)'],
[['hsl(0, 100%, 50%)', { s: 25 }], 'hsl(0, 100%, 50%)'],
[['hsl(0, 0%, 50%)', { s: -25 }], 'hsl(0, 0%, 50%)'],
[['hsla(0, 0%, 50%, .5)', { s: -25 }], 'hsla(0, 0%, 50%, 0.5)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( Color.format.hsl.stringify ( Color.parse ( adjust ( ...args ) ) ), output );
});
});
it ( 'increases or decreases the value of the alpha channel of the color', t => {
const tests = [
[['rgba(0, 0, 0, 0)', { a: 0.5 }], 'rgba(0, 0, 0, 0.5)'],
[['hsla(0, 0%, 0%, 0)', { a: 0.5 }], 'hsla(0, 0%, 0%, 0.5)'],
[['rgba(0, 0, 0, 0)', { a: 1 }], '#000000'],
[['rgba(0, 0, 0, 1)', { a: -0.5 }], 'rgba(0, 0, 0, 0.5)'],
[['rgba(0, 0, 0, 1)', { a: -1 }], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', { a: 1 }], '#000000'],
[['rgba(0, 0, 0, 0.5)', { a: -1 }], 'rgba(0, 0, 0, 0)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( adjust ( ...args ), output );
});
});
it ( 'throws when setting RGB and HSL channels at the same time', t => {
const tests = [
['#000', { r: 10, h: 10 }],
['#000', { g: 10, l: 10 }],
['#000', { b: 10, s: 10 }]
];
tests.forEach ( args => {
t.throws ( () => adjust ( ...args ), /cannot.*at the same time/i );
});
});
});

26
node_modules/khroma/test/methods/alpha.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/* IMPORT */
import {describe} from 'fava';
import {alpha} from '../../dist/index.js';
/* MAIN */
describe ( 'alpha', it => {
it ( 'gets the alpha channel of the color', t => {
const tests = [
['rgba(10, 20, 30)', 1],
['rgba(10, 20, 30, 0.1)', 0.1],
['#10203040', 0.2509803922],
['hsla(10, 20%, 30%, 0.5)', 0.5]
];
tests.forEach ( ([ color, output ]) => {
t.is ( alpha ( color ), output );
});
});
});

25
node_modules/khroma/test/methods/blue.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {blue} from '../../dist/index.js';
/* MAIN */
describe ( 'blue', it => {
it ( 'gets the blue channel of the color', t => {
const tests = [
['rgb(10, 20, 30)', 30],
['#102030', 48],
['hsl(10, 20%, 30%)', 61.2]
];
tests.forEach ( ([ color, output ]) => {
t.is ( blue ( color ), output );
});
});
});

82
node_modules/khroma/test/methods/change.js generated vendored Normal file
View File

@@ -0,0 +1,82 @@
/* IMPORT */
import {describe} from 'fava';
import {change} from '../../dist/index.js';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'change', it => {
it ( 'sets a new value for any RGBA channel of the color', t => {
const tests = [
[['rgb(100, 100, 100)', { r: 0 }], 'rgb(0, 100, 100)'],
[['rgb(100, 100, 100)', { r: 255 }], 'rgb(255, 100, 100)'],
[['rgb(100, 100, 100)', { r: 100 }], 'rgb(100, 100, 100)'],
[['rgb(100, 100, 100)', { g: 0 }], 'rgb(100, 0, 100)'],
[['rgb(100, 100, 100)', { b: 0 }], 'rgb(100, 100, 0)'],
[['rgb(100, 100, 100)', { r: 50, g: 150 }], 'rgb(50, 150, 100)'],
[['rgb(100, 100, 100)', { r: 50, g: 150, b: 200 }], 'rgb(50, 150, 200)'],
[['rgb(100, 100, 100)', { r: 50, g: 150, b: 200, a: 0.5 }], 'rgba(50, 150, 200, 0.5)'],
[['rgb(100, 100, 100)', { r: 0, g: 0, b: 0, a: 0 }], 'rgba(0, 0, 0, 0)'],
[['rgba(100, 100, 100, .5)', { g: 0 }], 'rgba(100, 0, 100, 0.5)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( Color.format.rgb.stringify ( Color.parse ( change ( ...args ) ) ), output );
});
});
it ( 'sets a new value for any HSLA channel of the color', t => {
const tests = [
[['hsl(50, 50%, 50%)', { h: 100 }], 'hsl(100, 50%, 50%)'],
[['hsl(50, 50%, 50%)', { h: 400 }], 'hsl(40, 50%, 50%)'],
[['hsl(50, 50%, 50%)', { h: 0 }], 'hsl(0, 50%, 50%)'],
[['hsl(50, 50%, 50%)', { s: 25 }], 'hsl(50, 25%, 50%)'],
[['hsl(50, 50%, 50%)', { l: 25 }], 'hsl(50, 50%, 25%)'],
[['hsl(50, 50%, 50%)', { h: 100, s: 75 }], 'hsl(100, 75%, 50%)'],
[['hsl(50, 50%, 50%)', { h: 100, s: 75, l: 25 }], 'hsl(100, 75%, 25%)'],
[['hsl(50, 50%, 50%)', { h: 100, s: 75, l: 25, a: 0.5 }], 'hsla(100, 75%, 25%, 0.5)'],
[['hsl(50, 50%, 50%)', { h: 0, s: 0, l: 0, a: 0 }], 'hsla(0, 0%, 0%, 0)'],
[['hsla(50, 50%, 50%, 0.5)', { h: 360, s: 100, l: 100, a: 1 }], 'hsl(0, 100%, 100%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( Color.format.hsl.stringify ( Color.parse ( change ( ...args ) ) ), output );
});
});
it ( 'sets a new value for the alpha channel of the color', t => {
const tests = [
[['rgba(0, 0, 0, 0)', { a: 0.5 }], 'rgba(0, 0, 0, 0.5)'],
[['hsla(0, 0%, 0%, 0.25)', { a: 0.5 }], 'hsla(0, 0%, 0%, 0.5)'],
[['rgba(0, 0, 0, 1)', { a: 1 }], '#000000']
];
tests.forEach ( ([ args, output ]) => {
t.is ( change ( ...args ), output );
});
});
it ( 'throws when setting RGB and HSL channels at the same time', t => {
const tests = [
['#000', { r: 0, h: 0 }],
['#000', { g: 0, l: 0 }],
['#000', { b: 0, s: 0 }]
];
tests.forEach ( args => {
t.throws ( () => change ( ...args ), /cannot.*at the same time/i );
});
});
});

25
node_modules/khroma/test/methods/complement.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {complement} from '../../dist/index.js';
/* MAIN */
describe ( 'complement', it => {
it ( 'gets the complement of the color', t => {
const tests = [
['#6b717f', 'hsl(42, 8.547008547%, 45.8823529412%)'],
['#d2e1dd', 'hsl(344, 20%, 85.2941176471%)'],
['#036', 'hsl(30, 100%, 20%)']
];
tests.forEach ( ([ color, output ]) => {
t.is ( complement ( color ), output );
});
});
});

28
node_modules/khroma/test/methods/contrast.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {contrast} from '../../dist/index.js';
/* MAIN */
describe ( 'contrast', it => {
it ( 'gets the contrast ratio between two colors', t => {
const tests = [
['#000000', '#000000', 1],
['#ffffff', '#ffffff', 1],
['#000000', '#ffffff', 10],
['#ffffff', '#000000', 10],
['#888888', '#ffffff', 4.0617165366],
['#ffffff', '#888888', 4.0617165366]
];
tests.forEach ( ([ color1, color2, output ]) => {
t.is ( contrast ( color1, color2 ), output );
});
});
});

27
node_modules/khroma/test/methods/darken.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/* IMPORT */
import {describe} from 'fava';
import {darken} from '../../dist/index.js';
/* MAIN */
describe ( 'darken', it => {
it ( 'decreases the lightness channel of the color', t => {
const tests = [
[['hsl(0, 0%, 100%)', 0], 'hsl(0, 0%, 100%)'],
[['hsl(0, 0%, 100%)', 50], 'hsl(0, 0%, 50%)'],
[['hsl(0, 0%, 100%)', 75], 'hsl(0, 0%, 25%)'],
[['hsl(0, 0%, 100%)', 100], 'hsl(0, 0%, 0%)'],
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 0%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( darken ( ...args ), output );
});
});
});

28
node_modules/khroma/test/methods/desaturate.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {desaturate} from '../../dist/index.js';
/* MAIN */
describe ( 'desaturate', it => {
it ( 'decreases the saturation channel of the color', t => {
const tests = [
[['hsl(0, 100%, 50%)', 0], 'hsl(0, 100%, 50%)'],
[['hsl(0, 100%, 50%)', 50], 'hsl(0, 50%, 50%)'],
[['hsl(0, 100%, 50%)', 75], 'hsl(0, 25%, 50%)'],
[['hsl(0, 100%, 50%)', 100], 'hsl(0, 0%, 50%)'],
[['hsl(0, 50%, 50%)', 100], 'hsl(0, 0%, 50%)'],
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 50%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( desaturate ( ...args ), output );
});
});
});

25
node_modules/khroma/test/methods/grayscale.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {grayscale} from '../../dist/index.js';
/* MAIN */
describe ( 'grayscale', it => {
it ( 'gets the grayscale version of the color', t => {
const tests = [
['#6b717f', 'hsl(222, 0%, 45.8823529412%)'],
['#d2e1dd', 'hsl(164, 0%, 85.2941176471%)'],
['#036', 'hsl(210, 0%, 20%)']
];
tests.forEach ( ([ color, output ]) => {
t.is ( grayscale ( color ), output );
});
});
});

25
node_modules/khroma/test/methods/green.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {green} from '../../dist/index.js';
/* MAIN */
describe ( 'green', it => {
it ( 'gets the green channel of the color', t => {
const tests = [
['rgb(10, 20, 30)', 20],
['#102030', 32],
['hsl(10, 20%, 30%)', 66.3]
];
tests.forEach ( ([ color, output ]) => {
t.is ( green ( color ), output );
});
});
});

41
node_modules/khroma/test/methods/hex.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
/* IMPORT */
import {describe} from 'fava';
import {hex} from '../../dist/index.js';
/* MAIN */
describe ( 'hex', it => {
it ( 'creates a new color given its rgba channels', t => {
const tests = [
[[0, 0, 0, 0], 'rgba(0, 0, 0, 0)'],
[[255, 255, 255, 0.5], 'rgba(255, 255, 255, 0.5)'],
[[0, 0, 0, 1], '#000000'],
[[128, 128, 128, 1], '#808080'],
[[-1, -1, -1, -1], 'rgba(0, 0, 0, 0)'],
[[1000, 1000, 1000, 1000], '#ffffff']
];
tests.forEach ( ([ args, output ]) => {
t.is ( hex ( ...args ), output );
});
});
it ( 'allows ommiting the alpha channel', t => {
const tests = [
[[0, 0, 0], '#000000'],
[[255, 255, 255], '#ffffff']
];
tests.forEach ( ([ args, output ]) => {
t.is ( hex ( ...args ), output );
});
});
});

41
node_modules/khroma/test/methods/hsla.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
/* IMPORT */
import {describe} from 'fava';
import {hsla} from '../../dist/index.js';
/* MAIN */
describe ( 'hsla', it => {
it ( 'creates a new color given its hsla channels.', t => {
const tests = [
[[0, 0, 0, 0], 'hsla(0, 0%, 0%, 0)'],
[[0, 0, 0, 0.5], 'hsla(0, 0%, 0%, 0.5)'],
[[0, 0, 0, 1], 'hsl(0, 0%, 0%)'],
[[180, 50, 50, 1], 'hsl(180, 50%, 50%)'],
[[-1, -1, -1, -1], 'hsla(-1, 0%, 0%, 0)'],
[[1000, 1000, 1000, 1000], 'hsl(280, 100%, 100%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( hsla ( ...args ), output );
});
});
it ( 'allows ommiting the alpha channel', t => {
const tests = [
[[0, 0, 0], 'hsl(0, 0%, 0%)'],
[[180, 50, 50], 'hsl(180, 50%, 50%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( hsla ( ...args ), output );
});
});
});

25
node_modules/khroma/test/methods/hue.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {hue} from '../../dist/index.js';
/* MAIN */
describe ( 'hue', it => {
it ( 'gets the hue channel of the color', t => {
const tests = [
['hsl(10, 20%, 30%)', 10],
['rgb(10, 20, 30)', 210],
['#102030', 210]
];
tests.forEach ( ([ color, output ]) => {
t.is ( hue ( color ), output );
});
});
});

25
node_modules/khroma/test/methods/invert.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {invert} from '../../dist/index.js';
/* MAIN */
describe ( 'invert', it => {
it ( 'gets the inverse of the color', t => {
const tests = [
[['#b37399'], '#4c8c66'],
[['black'], '#ffffff'],
[['#550e0c', 20 ], 'rgb(102, 59.4, 58.2)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( invert ( ...args ), output );
});
});
});

28
node_modules/khroma/test/methods/is_dark.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {isDark} from '../../dist/index.js';
/* MAIN */
describe ( 'isDark', it => {
it ( 'checks if the provided color is a dark color', t => {
const tests = [
['#000000', true],
['#8a8a8a', true],
['#bbbbbb', true],
['#ffcc00', false],
['#e0e0e0', false],
['#ffffff', false]
];
tests.forEach ( ([ color, output ]) => {
t.is ( isDark ( color ), output );
});
});
});

28
node_modules/khroma/test/methods/is_light.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {isLight} from '../../dist/index.js';
/* MAIN */
describe ( 'isLight', it => {
it ( 'checks if the provided color is a light color', t => {
const tests = [
['#000000', false],
['#8a8a8a', false],
['#bbbbbb', false],
['#ffcc00', true],
['#e0e0e0', true],
['#ffffff', true]
];
tests.forEach ( ([ color, output ]) => {
t.is ( isLight ( color ), output );
});
});
});

28
node_modules/khroma/test/methods/is_valid.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {isValid} from '../../dist/index.js';
/* MAIN */
describe ( 'isValid', it => {
it ( 'checks if the provided color is a valid color', t => {
const tests = [
['black', true],
['rgb(10, 20, 30)', true],
['#102030', true],
['hsl(10, 20%, 30%)', true],
['#ggg', false],
['foo', false]
];
tests.forEach ( ([ color, output ]) => {
t.is ( isValid ( color ), output );
});
});
});

28
node_modules/khroma/test/methods/lighten.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {lighten} from '../../dist/index.js';
/* MAIN */
describe ( 'lighten', it => {
it ( 'increases the lightness channel of the color', t => {
const tests = [
[['hsl(0, 0%, 0%)', 0], 'hsl(0, 0%, 0%)'],
[['hsl(0, 0%, 0%)', 50], 'hsl(0, 0%, 50%)'],
[['hsl(0, 0%, 0%)', 75], 'hsl(0, 0%, 75%)'],
[['hsl(0, 0%, 0%)', 100], 'hsl(0, 0%, 100%)'],
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 0%, 100%)'],
[['hsl(0, 0%, 100%)', 100], 'hsl(0, 0%, 100%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( lighten ( ...args ), output );
});
});
});

26
node_modules/khroma/test/methods/lightness.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/* IMPORT */
import {describe} from 'fava';
import {lightness} from '../../dist/index.js';
/* MAIN */
describe ( 'lightness', it => {
it ( 'gets the lightness channel of the color', t => {
const tests = [
['hsl(10, 20%, 30%)', 30],
['rgb(10, 20, 30)', 7.8431372549],
['rgb(0, 0, 0)', 0],
['#102030', 12.5490196078]
];
tests.forEach ( ([ color, output ]) => {
t.is ( lightness ( color ), output );
});
});
});

28
node_modules/khroma/test/methods/luminance.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {luminance} from '../../dist/index.js';
/* MAIN */
describe ( 'luminance', it => {
it ( 'gets the relative luminance of the color', t => {
const tests = [
['#000000', 0],
['#8a8a8a', .2541520943],
['#bbbbbb', .4969329951],
['#ffcc00', .6444573127],
['#e0e0e0', .7454042095],
['#ffffff', 1]
];
tests.forEach ( ([ color, output ]) => {
t.is ( luminance ( color ), output );
});
});
});

26
node_modules/khroma/test/methods/mix.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/* IMPORT */
import {describe} from 'fava';
import {mix} from '../../dist/index.js';
/* MAIN */
describe ( 'mix', it => {
it ( 'mixes two colors together', t => {
const tests = [
[['#036', '#d2e1dd'], 'rgb(105, 138, 161.5)'],
[['#036', '#d2e1dd', 75 ], 'rgb(52.5, 94.5, 131.75)'],
[['#036', '#d2e1dd', 25 ], 'rgb(157.5, 181.5, 191.25)'],
[['rgba(242, 236, 228, 0.5)', '#6b717f'], 'rgba(140.75, 143.75, 152.25, 0.75)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( mix ( ...args ), output );
});
});
});

25
node_modules/khroma/test/methods/opacify.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {opacify} from '../../dist/index.js';
/* MAIN */
describe ( 'opacify', it => {
it ( 'increases the opacity channel of the color', t => {
const tests = [
[['#000000', 1], '#000000'],
[['rgba(0, 0, 0, 0.5)', 0.5], '#000000'],
[['rgba(0, 0, 0, 0.5)', 0.1], 'rgba(0, 0, 0, 0.6)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( opacify ( ...args ), output );
});
});
});

25
node_modules/khroma/test/methods/red.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/* IMPORT */
import {describe} from 'fava';
import {red} from '../../dist/index.js';
/* MAIN */
describe ( 'red', it => {
it ( 'gets the red channel of the color', t => {
const tests = [
['rgb(10, 20, 30)', 10],
['#102030', 16],
['hsl(10, 20%, 30%)', 91.8]
];
tests.forEach ( ([ color, output ]) => {
t.is ( red ( color ), output );
});
});
});

58
node_modules/khroma/test/methods/rgba.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
/* IMPORT */
import {describe} from 'fava';
import {rgba} from '../../dist/index.js';
/* MAIN */
describe ( 'rgba', it => {
it ( 'creates a new color given its rgba channels', t => {
const tests = [
[[0, 0, 0, 0], 'rgba(0, 0, 0, 0)'],
[[255, 255, 255, 0.5], 'rgba(255, 255, 255, 0.5)'],
[[0, 0, 0, 1], '#000000'],
[[128, 128, 128, 1], '#808080'],
[[-1, -1, -1, -1], 'rgba(0, 0, 0, 0)'],
[[1000, 1000, 1000, 1000], '#ffffff']
];
tests.forEach ( ([ args, output ]) => {
t.is ( rgba ( ...args ), output );
});
});
it ( 'sets the opacity', t => {
const tests = [
[['#000000', .5], 'rgba(0, 0, 0, 0.5)'],
[['#00000066', .5], 'rgba(0, 0, 0, 0.5)'],
[['#ffffff', .5], 'rgba(255, 255, 255, 0.5)'],
[['#ffffff66', .5], 'rgba(255, 255, 255, 0.5)'],
[['#ffcc00', .5], 'rgba(255, 204, 0, 0.5)'],
[['#ffcc0066', .5], 'rgba(255, 204, 0, 0.5)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( rgba ( ...args ), output );
});
});
it ( 'allows ommiting the alpha channel', t => {
const tests = [
[[0, 0, 0], '#000000'],
[[255, 255, 255], '#ffffff']
];
tests.forEach ( ([ args, output ]) => {
t.is ( rgba ( ...args ), output );
});
});
});

28
node_modules/khroma/test/methods/saturate.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
/* IMPORT */
import {describe} from 'fava';
import {saturate} from '../../dist/index.js';
/* MAIN */
describe ( 'saturate', it => {
it ( 'increases the saturation channel of the color', t => {
const tests = [
[['hsl(0, 0%, 50%)', 0], 'hsl(0, 0%, 50%)'],
[['hsl(0, 0%, 50%)', 50], 'hsl(0, 50%, 50%)'],
[['hsl(0, 0%, 50%)', 75], 'hsl(0, 75%, 50%)'],
[['hsl(0, 0%, 50%)', 100], 'hsl(0, 100%, 50%)'],
[['hsl(0, 50%, 50%)', 100], 'hsl(0, 100%, 50%)'],
[['hsl(0, 100%, 50%)', 100], 'hsl(0, 100%, 50%)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( saturate ( ...args ), output );
});
});
});

27
node_modules/khroma/test/methods/saturation.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
/* IMPORT */
import {describe} from 'fava';
import {saturation} from '../../dist/index.js';
/* MAIN */
describe ( 'saturation', it => {
it ( 'gets the saturation channel of the color', t => {
const tests = [
['hsl(10, 20%, 30%)', 20],
['rgb(10, 20, 30)', 50],
['rgb(0, 0, 0)', 0],
['#102030', 50],
['#ff0000', 100]
];
tests.forEach ( ([ color, output ]) => {
t.is ( saturation ( color ), output );
});
});
});

95
node_modules/khroma/test/methods/scale.js generated vendored Normal file
View File

@@ -0,0 +1,95 @@
/* IMPORT */
import {describe} from 'fava';
import {scale} from '../../dist/index.js';
import Color from '../../dist/color/index.js';
/* MAIN */
describe ( 'scale', it => {
it ( 'scales any RGBA channels of the color', t => {
const tests = [
[['rgb(0, 0, 0)', { r: 100 }], 'rgb(255, 0, 0)'],
[['rgb(0, 0, 0)', { r: 50 }], 'rgb(127.5, 0, 0)'],
[['rgb(0, 0, 0)', { r: 0 }], 'rgb(0, 0, 0)'],
[['rgb(255, 0, 0)', { r: -100 }], 'rgb(0, 0, 0)'],
[['rgb(255, 0, 0)', { r: -50 }], 'rgb(127.5, 0, 0)'],
[['rgb(255, 0, 0)', { r: -0 }], 'rgb(255, 0, 0)'],
[['rgb(0, 0, 0)', { g: 100 }], 'rgb(0, 255, 0)'],
[['rgb(0, 0, 0)', { g: 50 }], 'rgb(0, 127.5, 0)'],
[['rgb(0, 0, 0)', { g: 0 }], 'rgb(0, 0, 0)'],
[['rgb(0, 0, 0)', { b: 100 }], 'rgb(0, 0, 255)'],
[['rgb(0, 0, 0)', { b: 50 }], 'rgb(0, 0, 127.5)'],
[['rgb(0, 0, 0)', { b: 0 }], 'rgb(0, 0, 0)'],
[['rgb(0, 0, 0)', { r: 50, g: 50, b: 50 }], 'rgb(127.5, 127.5, 127.5)'],
[['rgba(0, 0, 0, .5)', { b: 0 }], 'rgba(0, 0, 0, 0.5)']
];
tests.forEach ( ([ args, ouptut ]) => {
t.is ( Color.format.rgb.stringify ( Color.parse ( scale ( ...args ) ) ), ouptut );
});
});
it ( 'scales any HSLA channels of the color', t => {
const tests = [
[['hsl(0, 50%, 50%)', { h: 100 }], 'hsl(0, 50%, 50%)'], // Wraps becuase 360deg = 0deg
[['hsl(0, 50%, 50%)', { h: 50 }], 'hsl(180, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { h: 0 }], 'hsl(0, 50%, 50%)'],
[['hsl(180, 50%, 50%)', { h: -100 }], 'hsl(0, 50%, 50%)'],
[['hsl(180, 50%, 50%)', { h: -50 }], 'hsl(90, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { s: 100 }], 'hsl(0, 100%, 50%)'],
[['hsl(0, 50%, 50%)', { s: 50 }], 'hsl(0, 75%, 50%)'],
[['hsl(0, 50%, 50%)', { s: 0 }], 'hsl(0, 50%, 50%)'],
[['hsl(0, 50%, 50%)', { s: -100 }], 'hsl(0, 0%, 50%)'],
[['hsl(0, 50%, 50%)', { s: -50 }], 'hsl(0, 25%, 50%)'],
[['hsl(0, 50%, 50%)', { l: 100 }], 'hsl(0, 50%, 100%)'],
[['hsl(0, 50%, 50%)', { l: 50 }], 'hsl(0, 50%, 75%)'],
[['hsl(0, 50%, 50%)', { l: 0 }], 'hsl(0, 50%, 50%)'],
[['hsla(0, 50%, 50%, .5)', { l: 0 }], 'hsla(0, 50%, 50%, 0.5)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( Color.format.hsl.stringify ( Color.parse ( scale ( ...args ) ) ), output );
});
});
it ( 'scales the alpha channel', t => {
const tests = [
[['rgba(0, 0, 0, 0)', { a: 0 }], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0)', { a: 50 }], 'rgba(0, 0, 0, 0.5)'],
[['rgba(0, 0, 0, 0)', { a: 100 }], '#000000'],
[['hsla(0, 0%, 0%, 0)', { a: 50 }], 'hsla(0, 0%, 0%, 0.5)'],
[['rgba(0, 0, 0, 1)', { a: -50 }], 'rgba(0, 0, 0, 0.5)'],
[['rgba(0, 0, 0, 1)', { a: -100 }], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', { a: 100 }], '#000000'],
[['rgba(0, 0, 0, 0.5)', { a: -100 }], 'rgba(0, 0, 0, 0)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( scale ( ...args ), output );
});
});
it ( 'throws when setting RGB and HSL channels at the same time', t => {
const tests = [
['#000', { r: 10, h: 10 }],
['#000', { g: 10, l: 10 }],
['#000', { b: 10, s: 10 }]
];
tests.forEach ( args => {
t.throws ( () => scale ( ...args ), /cannot.*at the same time/i );
});
});
});

26
node_modules/khroma/test/methods/transparentize.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
/* IMPORT */
import {describe} from 'fava';
import {transparentize} from '../../dist/index.js';
/* MAIN */
describe ( 'transparentize', it => {
it ( 'decreases the opacity channel of the color', t => {
const tests = [
[['#000000', 1], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', 0.5], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', 1], 'rgba(0, 0, 0, 0)'],
[['rgba(0, 0, 0, 0.5)', 0.1], 'rgba(0, 0, 0, 0.4)']
];
tests.forEach ( ([ args, output ]) => {
t.is ( transparentize ( ...args ), output );
});
});
});