46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
/*
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
import assert from 'node:assert/strict';
|
|
import { describe, it } from 'node:test';
|
|
import { createMaterialYouScheme, MATERIAL_YOU_STABLE_SEED } from './MaterialYouPalette.ts';
|
|
|
|
describe('createMaterialYouScheme', () => {
|
|
it('creates a deterministic stable blue light scheme', () => {
|
|
const first = createMaterialYouScheme(MATERIAL_YOU_STABLE_SEED, 'light');
|
|
const second = createMaterialYouScheme(MATERIAL_YOU_STABLE_SEED, 'light');
|
|
|
|
assert.deepEqual(first, second);
|
|
assert.equal(first.seed, '#5B74EF');
|
|
assert.equal(first.onSurface, '#171B2C');
|
|
assert.notEqual(first.surface, first.surfaceContainer);
|
|
});
|
|
|
|
it('orders dark tonal surfaces from darkest to lightest', () => {
|
|
const scheme = createMaterialYouScheme('#8F7CF7', 'dark');
|
|
|
|
assert.deepEqual(
|
|
[scheme.surface, scheme.surfaceContainer, scheme.surfaceContainerHigh],
|
|
['#11131A', '#191B23', '#24262F'],
|
|
);
|
|
assert.equal(scheme.onSurface, '#E4E6F0');
|
|
});
|
|
|
|
it('uses true black only for the base pure-black surface', () => {
|
|
const scheme = createMaterialYouScheme('#5B74EF', 'dark', true);
|
|
|
|
assert.equal(scheme.surface, '#000000');
|
|
assert.notEqual(scheme.surfaceContainer, '#000000');
|
|
assert.notEqual(scheme.primary, scheme.onPrimary);
|
|
});
|
|
|
|
it('normalizes invalid seeds to the stable seed', () => {
|
|
assert.deepEqual(createMaterialYouScheme('not-a-color', 'dark'), createMaterialYouScheme('#5B74EF', 'dark'));
|
|
});
|
|
});
|