Fix custom color backup import/export
This commit is contained in:
parent
734929f74f
commit
c7dc4279a1
8 changed files with 96 additions and 31 deletions
35
ts/test-node/util/hslToRGB_test.ts
Normal file
35
ts/test-node/util/hslToRGB_test.ts
Normal file
|
@ -0,0 +1,35 @@
|
|||
// Copyright 2024 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { hslToRGB, hslToRGBInt } from '../../util/hslToRGB';
|
||||
|
||||
describe('hslToRGB', () => {
|
||||
it('converts pure rgb colors', () => {
|
||||
assert.deepStrictEqual(hslToRGB(0, 1, 0.5), { r: 255, g: 0, b: 0 });
|
||||
assert.deepStrictEqual(hslToRGB(120, 1, 0.5), { r: 0, g: 255, b: 0 });
|
||||
assert.deepStrictEqual(hslToRGB(240, 1, 0.5), { r: 0, g: 0, b: 255 });
|
||||
});
|
||||
|
||||
it('converts random sampled hsl colors', () => {
|
||||
assert.deepStrictEqual(hslToRGB(50, 0.233333, 0.41), {
|
||||
r: 129,
|
||||
g: 121,
|
||||
b: 80,
|
||||
});
|
||||
assert.deepStrictEqual(hslToRGB(170, 0.97, 0.1), {
|
||||
r: 1,
|
||||
g: 50,
|
||||
b: 42,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('hslToRGBInt', () => {
|
||||
it('converts pure rgb colors', () => {
|
||||
assert.equal(hslToRGBInt(0, 1, 0.5), 4294901760);
|
||||
assert.equal(hslToRGBInt(120, 1, 0.5), 4278255360);
|
||||
assert.equal(hslToRGBInt(240, 1, 0.5), 4278190335);
|
||||
});
|
||||
});
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { rgbToHSL } from '../../util/rgbToHSL';
|
||||
import { rgbIntToHSL, rgbToHSL } from '../../util/rgbToHSL';
|
||||
|
||||
describe('rgbToHSL', () => {
|
||||
it('converts pure rgb colors', () => {
|
||||
|
@ -40,3 +40,11 @@ describe('rgbToHSL', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('rgbIntToHSL', () => {
|
||||
it('converts pure rgb colors', () => {
|
||||
assert.deepStrictEqual(rgbIntToHSL(4294901760), { h: 0, s: 1, l: 0.5 });
|
||||
assert.deepStrictEqual(rgbIntToHSL(4278255360), { h: 120, s: 1, l: 0.5 });
|
||||
assert.deepStrictEqual(rgbIntToHSL(4278190335), { h: 240, s: 1, l: 0.5 });
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue