Skip to content

Commit

Permalink
Increases testing for xspace
Browse files Browse the repository at this point in the history
  • Loading branch information
mster committed May 17, 2021
1 parent 98887d3 commit fe02b4f
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions tests/test.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,26 +577,33 @@ describe("Utility", () => {
const { xspace } = utils;

const rgb = { r: 0, g: 0, b: 0 };

const expectedRgbRgb = rgb;
const acutalRgbRgb = xspace(rgb, "rgb");

expect(acutalRgbRgb).toEqual(expectedRgbRgb);

const expectedRgbHex = "000000";
const actualRgbHex = xspace(rgb, "hex");

expect(actualRgbHex).toEqual(expectedRgbHex);

const expectedRgbHsv = { h: 0, s: 0, v: 0 };
const actualRgbHsv = xspace(rgb, "hsv");

expect(actualRgbHsv).toEqual(expectedRgbHsv);

const expectedRgbHsl = { h: 0, s: 0, l: 0 };
const actualRgbHsl = xspace(rgb, "hsl");

expect(actualRgbHsl).toEqual(expectedRgbHsl);
const hex = "000000";
const hsv = { h: 0, s: 0, v: 0 };
const hsl = { h: 0, s: 0, l: 0 };

// rgb to ...
expect(xspace(rgb, "hex")).toEqual(hex);
expect(xspace(rgb, "rgb")).toEqual(rgb);
expect(xspace(rgb, "hsv")).toEqual(hsv);
expect(xspace(rgb, "hsl")).toEqual(hsl);

// hex to ...
expect(xspace(hex, "hex")).toEqual(hex);
expect(xspace(hex, "rgb")).toEqual(rgb);
expect(xspace(hex, "hsv")).toEqual(hsv);
expect(xspace(hex, "hsl")).toEqual(hsl);

// hsv to ...
expect(xspace(hsv, "hex")).toEqual(hex);
expect(xspace(hsv, "rgb")).toEqual(rgb);
expect(xspace(hsv, "hsv")).toEqual(hsv);
expect(xspace(hsv, "hsl")).toEqual(hsl);

// hsl to ...
expect(xspace(hsl, "hex")).toEqual(hex);
expect(xspace(hsl, "rgb")).toEqual(rgb);
expect(xspace(hsl, "hsv")).toEqual(hsv);
expect(xspace(hsl, "hsl")).toEqual(hsl);
});

test("xspace should throw when provided with an invalid color or map.", () => {
Expand Down

0 comments on commit fe02b4f

Please sign in to comment.