mirror of
https://github.com/nunocoracao/blowfish.git
synced 2026-01-30 16:31:52 +01:00
config redirect
This commit is contained in:
89
node_modules/khroma/test/methods/adjust.js
generated
vendored
Normal file
89
node_modules/khroma/test/methods/adjust.js
generated
vendored
Normal 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
26
node_modules/khroma/test/methods/alpha.js
generated
vendored
Normal 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
25
node_modules/khroma/test/methods/blue.js
generated
vendored
Normal 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
82
node_modules/khroma/test/methods/change.js
generated
vendored
Normal 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
25
node_modules/khroma/test/methods/complement.js
generated
vendored
Normal 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
28
node_modules/khroma/test/methods/contrast.js
generated
vendored
Normal 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
27
node_modules/khroma/test/methods/darken.js
generated
vendored
Normal 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
28
node_modules/khroma/test/methods/desaturate.js
generated
vendored
Normal 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
25
node_modules/khroma/test/methods/grayscale.js
generated
vendored
Normal 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
25
node_modules/khroma/test/methods/green.js
generated
vendored
Normal 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
41
node_modules/khroma/test/methods/hex.js
generated
vendored
Normal 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
41
node_modules/khroma/test/methods/hsla.js
generated
vendored
Normal 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
25
node_modules/khroma/test/methods/hue.js
generated
vendored
Normal 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
25
node_modules/khroma/test/methods/invert.js
generated
vendored
Normal 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
28
node_modules/khroma/test/methods/is_dark.js
generated
vendored
Normal 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
28
node_modules/khroma/test/methods/is_light.js
generated
vendored
Normal 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
28
node_modules/khroma/test/methods/is_valid.js
generated
vendored
Normal 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
28
node_modules/khroma/test/methods/lighten.js
generated
vendored
Normal 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
26
node_modules/khroma/test/methods/lightness.js
generated
vendored
Normal 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
28
node_modules/khroma/test/methods/luminance.js
generated
vendored
Normal 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
26
node_modules/khroma/test/methods/mix.js
generated
vendored
Normal 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
25
node_modules/khroma/test/methods/opacify.js
generated
vendored
Normal 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
25
node_modules/khroma/test/methods/red.js
generated
vendored
Normal 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
58
node_modules/khroma/test/methods/rgba.js
generated
vendored
Normal 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
28
node_modules/khroma/test/methods/saturate.js
generated
vendored
Normal 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
27
node_modules/khroma/test/methods/saturation.js
generated
vendored
Normal 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
95
node_modules/khroma/test/methods/scale.js
generated
vendored
Normal 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
26
node_modules/khroma/test/methods/transparentize.js
generated
vendored
Normal 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 );
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user