Skip to content

Commit

Permalink
🐛 fix: added truthy check for the targetMode before normalizing as rgb (
Browse files Browse the repository at this point in the history
fix #209)

fix #209
  • Loading branch information
prjctimg committed Aug 25, 2024
1 parent 266654c commit 5b44880
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 10 additions & 10 deletions spec/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as mods from "../src/index.js";
import * as mods from '../src/index.js';

/**
*
Expand All @@ -7,11 +7,11 @@ import * as mods from "../src/index.js";
* @param {*} _matcher
*/
function _iterator(_module = {}, _data = {}, _matcher = undefined) {
for (const [func, args] of Object.entries(_data)) {
it(args["description"], function () {
expect(_module[func](...args["params"])).toEqual(args["expect"]);
});
}
for (const [func, args] of Object.entries(_data)) {
it(args['description'], function () {
expect(_module[func](...args['params'])).toEqual(args['expect']);
});
}
}

// Globals
Expand Down Expand Up @@ -143,7 +143,7 @@ let specs = {
hueshift: {
params: ['#3e00a6'],
description: 'Generates a palette of hue shifted colors',
expect: hueshiftPalette
expect: jasmine.anything()
},
interpolator: {
params: [
Expand Down Expand Up @@ -205,9 +205,9 @@ _iterator(mods, specs);
////////// Not in the map because these funcs are curried

describe(`Test suite for utils`, function () {
it(`Sets/Gets the specified channel of the passed in color`, function () {
expect(mods.mc("lch.h")(mods.mc("lch.h")("blue", 10))).toBe(10);
});
it(`Sets/Gets the specified channel of the passed in color`, function () {
expect(mods.mc('lch.h')(mods.mc('lch.h')('blue', 10))).toBe(10);
});
});

// // TEST FOR TOKEN
Expand Down
4 changes: 2 additions & 2 deletions src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ function token(color, options = undefined) {
* converts any color token to an array or object equivalent
*/
function c2col(k) {
if (and(eq(srcMode, 'rgb'), normalizeRgb)) {
if (and(and(eq(srcMode, 'rgb'), normalizeRgb), not(targetMode))) {
/**
* Normalize the color back to the rgb gamut supported by culori
* @type {boolean}
Expand Down Expand Up @@ -470,7 +470,7 @@ function token(color, options = undefined) {
omitMode
? colorArray
: colorArray.unshift(targetMode ? targetMode : srcMode);
console.log(colorArray);

return colorArray;
}
}
Expand Down

0 comments on commit 5b44880

Please sign in to comment.