Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/modules/color/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function toCSS(
case 'hsla': {
return `hsl(${values[0]}deg ${toPercentage(values[1])}% ${toPercentage(
values[2]
)}% / ${toPercentage(values[3])})`;
)}% / ${values[3]})`;
}

case 'hwb': {
Expand Down Expand Up @@ -897,10 +897,11 @@ export class ColorModule extends ModuleBase {
}): string | number[];
lch(options: { format?: ColorFormat } = {}): string | number[] {
const { format = 'decimal' } = options;
const lch = [this.faker.number.float({ multipleOf: 0.000001 })];
for (let i = 0; i < 2; i++) {
lch.push(this.faker.number.float({ max: 230, multipleOf: 0.1 }));
}
const lch = [
this.faker.number.float({ multipleOf: 0.000001 }),
this.faker.number.float({ max: 230, multipleOf: 0.1 }),
this.faker.number.float({ max: 360, multipleOf: 0.1 }),
];

return toColorFormat(lch, format, 'lch');
}
Expand Down
6 changes: 3 additions & 3 deletions test/modules/__snapshots__/color.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ exports[`color > 42 > lch 1`] = `
[
0.37454,
218.7,
168.4,
263.5,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why hsla doesnt show up as changed.

]
`;

Expand Down Expand Up @@ -110,7 +110,7 @@ exports[`color > 1211 > lch 1`] = `
[
0.928521,
205.5,
51.9,
81.2,
]
`;

Expand Down Expand Up @@ -169,7 +169,7 @@ exports[`color > 1337 > lch 1`] = `
[
0.262024,
36.5,
63.9,
100.1,
]
`;

Expand Down
16 changes: 8 additions & 8 deletions test/modules/color.spec.ts

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add test for hsla format.

Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ describe('color', () => {
expect(color).length(3);
expect(color[0]).toBeGreaterThanOrEqual(0);
expect(color[0]).toBeLessThanOrEqual(1);
for (const value of color) {
expect(value).toBeGreaterThanOrEqual(0);
expect(value).toBeLessThanOrEqual(230);
}
expect(color[1]).toBeGreaterThanOrEqual(0);
expect(color[1]).toBeLessThanOrEqual(230);
expect(color[2]).toBeGreaterThanOrEqual(0);
expect(color[2]).toBeLessThanOrEqual(360);
});
});

Expand All @@ -338,10 +338,10 @@ describe('color', () => {
expect(color).length(3);
expect(color[0]).toBeGreaterThanOrEqual(0);
expect(color[0]).toBeLessThanOrEqual(1);
for (const value of color) {
expect(value).toBeGreaterThanOrEqual(0);
expect(value).toBeLessThanOrEqual(230);
}
expect(color[1]).toBeGreaterThanOrEqual(0);
expect(color[1]).toBeLessThanOrEqual(230);
expect(color[2]).toBeGreaterThanOrEqual(0);
expect(color[2]).toBeLessThanOrEqual(360);
});
});

Expand Down